summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_allocator_local_cache.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-07-22 19:02:59 +0000
committerKostya Serebryany <kcc@google.com>2016-07-22 19:02:59 +0000
commit3aeb91b7f970d35265202300b37cc5ca7806422e (patch)
treee818f580ac0f5cc86b8be3c589e093a1069685ec /lib/sanitizer_common/sanitizer_allocator_local_cache.h
parent29ebba12cf19d91edbf78acd09ae97ae1a65f180 (diff)
[sanitizer] revert r276383 while investigating failures on bot
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276456 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.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h
index 780c45c0c..5c42707c6 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->Get(i);
- c->count = b->Count();
+ CHECK_GT(b->count, 0);
+ for (uptr i = 0; i < b->count; i++)
+ c->batch[i] = b->batch[i];
+ c->count = b->count;
DestroyBatch(class_id, allocator, b);
}
@@ -121,11 +121,13 @@ 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);
- b->SetFromArray(c->batch, cnt);
- for (uptr i = 0; i < cnt; i++)
+ for (uptr i = 0; i < cnt; i++) {
+ b->batch[i] = c->batch[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);
}
};