Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-07-19 14:40:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-07-19 14:40:57 +0400
commitbc5ecbc393340444344f22489cdffd19a5294528 (patch)
treec0e2376183598102db599008ed2b02378defdb56
parent3daa153d745766d119f5095baeef55ae570aed03 (diff)
optimization: avoid extra loop in BLI_mempool_destroy(). free the list inline.
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 87179a93e83..217a4b9d266 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -437,19 +437,22 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
void BLI_mempool_destroy(BLI_mempool *pool)
{
BLI_mempool_chunk *mpchunk = NULL;
+ BLI_mempool_chunk *mpchunk_next;
if (pool->flag & BLI_MEMPOOL_SYSMALLOC) {
- for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) {
+ for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk_next) {
+ mpchunk_next = mpchunk->next;
free(mpchunk->data);
+ free(mpchunk);
}
- BLI_freelist(&(pool->chunks));
free(pool);
}
else {
- for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) {
+ for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk_next) {
+ mpchunk_next = mpchunk->next;
MEM_freeN(mpchunk->data);
+ MEM_freeN(mpchunk);
}
- BLI_freelistN(&(pool->chunks));
MEM_freeN(pool);
}
}