diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-10-03 18:44:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-10-03 18:44:33 +0400 |
commit | f5eb8803583b96b605a3116ab00be138a90bb0c2 (patch) | |
tree | e76db7b479acac8d9e58dfea97ff979049819727 /source/blender/blenlib/intern/BLI_mempool.c | |
parent | c819fd4ee0b935dd88f2b516c4d49332af447f03 (diff) |
freeing mempool elements now fills freed memory with --debug for debug builds.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_mempool.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 8301a7df35b..067ddf91794 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -66,6 +66,10 @@ /* when undefined, merge the allocs for BLI_mempool_chunk and its data */ // #define USE_DATA_PTR +#ifdef DEBUG +static bool mempool_debug_memset = false; +#endif + /** * A free element from #BLI_mempool_chunk. Data is cast to this type and stored in * #BLI_mempool.free as a single linked list, each item #BLI_mempool.esize large. @@ -342,6 +346,11 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) BLI_assert(!"Attempt to free data which is not in pool.\n"); } } + + /* enable for debugging */ + if (UNLIKELY(mempool_debug_memset)) { + memset(addr, 255, pool->esize); + } #endif if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { @@ -609,3 +618,10 @@ void BLI_mempool_destroy(BLI_mempool *pool) MEM_freeN(pool); } } + +#ifdef DEBUG +void BLI_mempool_set_memory_debug(void) +{ + mempool_debug_memset = true; +} +#endif |