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_local_cache.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_local_cache.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_local_cache.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h index 5c42707c6..780c45c0c 100644 --- a/lib/sanitizer_common/sanitizer_allocator_local_cache.h +++ b/lib/sanitizer_common/sanitizer_allocator_local_cache.h @@ -109,10 +109,10 @@ struct SizeClassAllocatorLocalCache { InitCache(); PerClass *c = &per_class_[class_id]; Batch *b = allocator->AllocateBatch(&stats_, this, class_id); - CHECK_GT(b->count, 0); - for (uptr i = 0; i < b->count; i++) - c->batch[i] = b->batch[i]; - c->count = b->count; + CHECK_GT(b->Count(), 0); + for (uptr i = 0; i < b->Count(); i++) + c->batch[i] = b->Get(i); + c->count = b->Count(); DestroyBatch(class_id, allocator, b); } @@ -121,13 +121,11 @@ struct SizeClassAllocatorLocalCache { PerClass *c = &per_class_[class_id]; Batch *b = CreateBatch(class_id, allocator, (Batch*)c->batch[0]); uptr cnt = Min(c->max_count / 2, c->count); - for (uptr i = 0; i < cnt; i++) { - b->batch[i] = c->batch[i]; + b->SetFromArray(c->batch, cnt); + for (uptr i = 0; i < cnt; i++) c->batch[i] = c->batch[i + c->max_count / 2]; - } - b->count = cnt; + c->count -= cnt; - CHECK_GT(b->count, 0); allocator->DeallocateBatch(&stats_, class_id, b); } }; |