diff options
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator_size_class_map.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_size_class_map.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h index 212614b2d..88c74fe01 100644 --- a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h +++ b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h @@ -96,9 +96,25 @@ class SizeClassMap { // For large size classes we use one of the chunks to store the batch. // sizeof(TransferBatch) must be a power of 2 for more efficient allocation. struct TransferBatch { + void SetFromRange(uptr region_beg, uptr beg_offset, uptr step, uptr count) { + count_ = count; + for (uptr i = 0; i < count; i++) + batch_[i] = (void*)(region_beg + beg_offset + i * step); + } + void SetFromArray(void *batch[], uptr count) { + count_ = count; + for (uptr i = 0; i < count; i++) + batch_[i] = batch[i]; + } + void *Get(uptr idx) { + CHECK_LT(idx, count_); + return batch_[idx]; + } + uptr Count() const { return count_; } TransferBatch *next; - uptr count; - void *batch[kMaxNumCached]; + private: + uptr count_; + void *batch_[kMaxNumCached]; }; static const uptr kBatchSize = sizeof(TransferBatch); COMPILER_CHECK((kBatchSize & (kBatchSize - 1)) == 0); @@ -209,4 +225,3 @@ class SizeClassMap { typedef SizeClassMap<17, 126, 16> DefaultSizeClassMap; typedef SizeClassMap<17, 62, 14> CompactSizeClassMap; template<class SizeClassAllocator> struct SizeClassAllocatorLocalCache; - |