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-10-05 08:38:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-10-05 08:38:08 +0400
commit2621d77f393b5c92111fc422eea83f6252f99464 (patch)
treeb8ecc507e02e2bb0cf46b0a2b66829b3a2326626 /source/blender/blenlib/intern/BLI_mempool.c
parent7a9bc838de58c306afc33c7d0dd158af655817e6 (diff)
use valgrind hints for memarena for better debugging info when using valgrind.
also quiet a false positive in BLI_mempool_free().
Diffstat (limited to 'source/blender/blenlib/intern/BLI_mempool.c')
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 067ddf91794..b7f90f01c82 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -366,8 +366,12 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
pool->totused--;
+#ifdef WITH_MEM_VALGRIND
+ VALGRIND_MEMPOOL_FREE(pool, addr);
+#endif
+
/* nothing is in use; free all the chunks except the first */
- if (pool->totused == 0) {
+ if (UNLIKELY(pool->totused == 0)) {
BLI_freenode *curnode = NULL;
char *tmpaddr = NULL;
unsigned int i;
@@ -380,6 +384,10 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
pool->totalloc = pool->pchunk;
#endif
+ /* temp alloc so valgrind doesn't complain when setting free'd blocks 'next' */
+#ifdef WITH_MEM_VALGRIND
+ VALGRIND_MEMPOOL_ALLOC(pool, CHUNK_DATA(first), pool->csize);
+#endif
pool->free = CHUNK_DATA(first); /* start of the list */
for (tmpaddr = CHUNK_DATA(first), i = 0; i < pool->pchunk; i++) {
curnode = ((BLI_freenode *)tmpaddr);
@@ -387,11 +395,11 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
curnode->next = (BLI_freenode *)tmpaddr;
}
curnode->next = NULL; /* terminate the list */
- }
#ifdef WITH_MEM_VALGRIND
- VALGRIND_MEMPOOL_FREE(pool, addr);
+ VALGRIND_MEMPOOL_FREE(pool, CHUNK_DATA(first));
#endif
+ }
}
int BLI_mempool_count(BLI_mempool *pool)