mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 12:16:49 +00:00
[scudo] Minor refactor on element address validation (NFC) (#119436)
This commit is contained in:
parent
e7e42ef116
commit
5a930339a5
@ -74,7 +74,7 @@ public:
|
||||
if (Next == nullptr) {
|
||||
X->Next = getEndOfListVal();
|
||||
} else {
|
||||
DCHECK_LE(static_cast<LinkTy>(Next - Base), Size);
|
||||
assertElementInRange(Next);
|
||||
X->Next = static_cast<LinkTy>(Next - Base);
|
||||
}
|
||||
}
|
||||
@ -88,16 +88,22 @@ public:
|
||||
}
|
||||
// Set `X->Prev` to `Prev`.
|
||||
void setPrev(T *X, T *Prev) const {
|
||||
DCHECK_LT(reinterpret_cast<uptr>(Prev),
|
||||
reinterpret_cast<uptr>(Base + Size));
|
||||
if (Prev == nullptr)
|
||||
if (Prev == nullptr) {
|
||||
X->Prev = getEndOfListVal();
|
||||
else
|
||||
} else {
|
||||
assertElementInRange(Prev);
|
||||
X->Prev = static_cast<LinkTy>(Prev - Base);
|
||||
}
|
||||
}
|
||||
|
||||
LinkTy getEndOfListVal() const { return T::EndOfListVal; }
|
||||
|
||||
private:
|
||||
void assertElementInRange(T *X) const {
|
||||
DCHECK_GE(reinterpret_cast<uptr>(X), reinterpret_cast<uptr>(Base));
|
||||
DCHECK_LE(static_cast<LinkTy>(X - Base), Size);
|
||||
}
|
||||
|
||||
protected:
|
||||
T *Base = nullptr;
|
||||
LinkTy Size = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user