diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-08 05:59:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-08 06:58:56 +0400 |
commit | 412826a504a95c45b561893aa9cbaebd00d63702 (patch) | |
tree | 79450ca22b6456da674ffdfea59f3b380cb125dd /source/blender/blenlib/intern/BLI_mempool.c | |
parent | cced07661a4fcfd156caec81073d97c060677a15 (diff) |
Mempool: delay allocating an initial chunk, its not always used
Diffstat (limited to 'source/blender/blenlib/intern/BLI_mempool.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index c8917897185..3c158faaa1b 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -311,10 +311,12 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem, #endif pool->totused = 0; - /* allocate the actual chunks */ - for (i = 0; i < maxchunks; i++) { - BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool); - lasttail = mempool_chunk_add(pool, mpchunk, lasttail); + if (totelem) { + /* allocate the actual chunks */ + for (i = 0; i < maxchunks; i++) { + BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool); + lasttail = mempool_chunk_add(pool, mpchunk, lasttail); + } } #ifdef WITH_MEM_VALGRIND |