diff options
Diffstat (limited to 'compiler-rt/lib/scudo/standalone/combined.h')
| -rw-r--r-- | compiler-rt/lib/scudo/standalone/combined.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h index fbbc7c8d228..4c1c1196bf8 100644 --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -45,7 +45,7 @@ public: NewHeader.State = Chunk::State::Available; Chunk::compareExchangeHeader(Allocator.Cookie, Ptr, &NewHeader, &Header); - void *BlockBegin = Chunk::getBlockBegin(Ptr, &Header); + void *BlockBegin = Allocator::getBlockBegin(Ptr, &NewHeader); const uptr ClassId = Header.ClassId; if (ClassId) Cache.deallocate(ClassId, BlockBegin); @@ -482,12 +482,19 @@ private: reportSanityCheckError("class ID"); } + static INLINE void *getBlockBegin(const void *Ptr, + Chunk::UnpackedHeader *Header) { + return reinterpret_cast<void *>(reinterpret_cast<uptr>(Ptr) - + Chunk::getHeaderSize() - + (Header->Offset << MinAlignmentLog)); + } + // Return the size of a chunk as requested during its allocation. INLINE uptr getSize(const void *Ptr, Chunk::UnpackedHeader *Header) { const uptr SizeOrUnusedBytes = Header->SizeOrUnusedBytes; if (Header->ClassId) return SizeOrUnusedBytes; - return SecondaryT::getBlockEnd(Chunk::getBlockBegin(Ptr, Header)) - + return SecondaryT::getBlockEnd(getBlockBegin(Ptr, Header)) - reinterpret_cast<uptr>(Ptr) - SizeOrUnusedBytes; } @@ -505,7 +512,7 @@ private: if (BypassQuarantine) { NewHeader.State = Chunk::State::Available; Chunk::compareExchangeHeader(Cookie, Ptr, &NewHeader, Header); - void *BlockBegin = Chunk::getBlockBegin(Ptr, Header); + void *BlockBegin = getBlockBegin(Ptr, &NewHeader); const uptr ClassId = NewHeader.ClassId; if (ClassId) { bool UnlockRequired; |

