summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-05-16 20:15:59 +0200
committerStefan Metzmacher <metze@samba.org>2011-05-17 08:22:21 +0200
commit7102105c8954627dc30a851327cf2642ac0783d5 (patch)
tree3f4d33a02f588bc7873f91ec0f5412aa6722ad51
parent14b662ee4f278764b9dfd620851e908d29f29fc4 (diff)
downloadsamba-7102105c8954627dc30a851327cf2642ac0783d5.tar.gz
samba-7102105c8954627dc30a851327cf2642ac0783d5.tar.bz2
samba-7102105c8954627dc30a851327cf2642ac0783d5.zip
talloc: make really sure only optimize realloc if there's only one pool chunk
*talloc_pool_objectcount(pool_tc) == 2 doesn't mean the one of the objects is the pool itself! So we better check for == 1 and calculate the chunk count. metze
-rw-r--r--lib/talloc/talloc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index fcd86d754a..f3ed9c8567 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1479,8 +1479,13 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
size_t new_chunk_size = TC_ALIGN16(TC_HDR_SIZE + size);
size_t space_needed;
size_t space_left;
+ unsigned int chunk_count = *talloc_pool_objectcount(pool_tc);
- if (*talloc_pool_objectcount(pool_tc) == 2) {
+ if (!(pool_tc->flags & TALLOC_FLAG_FREE)) {
+ chunk_count -= 1;
+ }
+
+ if (chunk_count == 1) {
/*
* optimize for the case where 'tc' is the only
* chunk in the pool.