Changeset View
Changeset View
Standalone View
Standalone View
lib/scudo/scudo_allocator_secondary.h
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void *Allocate(AllocatorStats *Stats, uptr Size, uptr Alignment) { | ||||
// offset and unused bytes field of the header stay small. | // offset and unused bytes field of the header stay small. | ||||
if (Alignment > MinAlignment) { | if (Alignment > MinAlignment) { | ||||
if (!IsAligned(UserBeg, Alignment)) { | if (!IsAligned(UserBeg, Alignment)) { | ||||
UserBeg = RoundUpTo(UserBeg, Alignment); | UserBeg = RoundUpTo(UserBeg, Alignment); | ||||
DCHECK_GE(UserBeg, MapBeg); | DCHECK_GE(UserBeg, MapBeg); | ||||
const uptr NewMapBeg = RoundDownTo(UserBeg - HeadersSize, PageSize) - | const uptr NewMapBeg = RoundDownTo(UserBeg - HeadersSize, PageSize) - | ||||
PageSize; | PageSize; | ||||
DCHECK_GE(NewMapBeg, MapBeg); | DCHECK_GE(NewMapBeg, MapBeg); | ||||
if (NewMapBeg != MapBeg) { | if (!SANITIZER_WINDOWS && NewMapBeg != MapBeg) { | ||||
AddressRange.Unmap(MapBeg, NewMapBeg - MapBeg); | AddressRange.Unmap(MapBeg, NewMapBeg - MapBeg); | ||||
MapBeg = NewMapBeg; | MapBeg = NewMapBeg; | ||||
} | } | ||||
UserEnd = UserBeg + UserSize; | UserEnd = UserBeg + UserSize; | ||||
} | } | ||||
const uptr NewMapEnd = RoundUpTo(UserEnd, PageSize) + PageSize; | const uptr NewMapEnd = RoundUpTo(UserEnd, PageSize) + PageSize; | ||||
if (NewMapEnd != MapEnd) { | if (!SANITIZER_WINDOWS && NewMapEnd != MapEnd) { | ||||
AddressRange.Unmap(NewMapEnd, MapEnd - NewMapEnd); | AddressRange.Unmap(NewMapEnd, MapEnd - NewMapEnd); | ||||
MapEnd = NewMapEnd; | MapEnd = NewMapEnd; | ||||
} | } | ||||
MapSize = MapEnd - MapBeg; | MapSize = MapEnd - MapBeg; | ||||
} | } | ||||
DCHECK_LE(UserEnd, MapEnd - PageSize); | DCHECK_LE(UserEnd, MapEnd - PageSize); | ||||
// Actually mmap the memory, preserving the guard pages on either side | // Actually mmap the memory, preserving the guard pages on either side | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |