diff options
author | Kostya Serebryany <kcc@google.com> | 2016-07-22 02:21:12 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-07-22 02:21:12 +0000 |
commit | e7c718abcb8834b3798ebd10a1339045c3dc0bab (patch) | |
tree | 3e7eac2cacd7c22f1c965412bedd1e597c043fbc /lib/sanitizer_common/sanitizer_allocator_size_class_map.h | |
parent | a8fa5b0ee48cbc56396f99fa863330cd437c99f1 (diff) |
[sanitizer] refactor TransferBatch to hide the implementation. NFC
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276383 91177308-0d34-0410-b5e6-96231b3b80d8
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; - |