diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-07 06:52:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-07 06:52:23 +0400 |
commit | 5c5d643938c975bda53f04013ce88486afca2ecf (patch) | |
tree | 40090272aba5b19db75180def11cb163a4a1c38f /source/blender | |
parent | 13d90ab8f7941e243bb61c397046e9981a91217e (diff) |
Mempool: use define for used freeword and correct define
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 1fccc0bdc0f..c8917897185 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -56,6 +56,7 @@ #endif #define FREEWORD MAKE_ID('f', 'r', 'e', 'e') +#define USEDWORD MAKE_ID('u', 's', 'e', 'd') /* currently totalloc isnt used */ // #define USE_TOTALLOC @@ -128,7 +129,7 @@ struct BLI_mempool { #define NODE_STEP_PREV(node) ((void *)((char *)(node) - esize)) /* extra bytes implicitly used for every chunk alloc */ -#ifdef USE_CHUNK_POW2 +#ifdef USE_DATA_PTR # define CHUNK_OVERHEAD (unsigned int)(MEM_SIZE_OVERHEAD + sizeof(BLI_mempool_chunk)) #else # define CHUNK_OVERHEAD (unsigned int)(MEM_SIZE_OVERHEAD) @@ -325,9 +326,7 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem, void *BLI_mempool_alloc(BLI_mempool *pool) { - void *retval = NULL; - - pool->totused++; + BLI_freenode *free_pop; if (UNLIKELY(pool->free == NULL)) { /* need to allocate a new chunk */ @@ -335,21 +334,22 @@ void *BLI_mempool_alloc(BLI_mempool *pool) mempool_chunk_add(pool, mpchunk, NULL); } - BLI_assert(pool->chunk_tail->next == NULL); + free_pop = pool->free; - retval = pool->free; + BLI_assert(pool->chunk_tail->next == NULL); if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { - pool->free->freeword = 0x7FFFFFFF; + free_pop->freeword = USEDWORD; } - pool->free = pool->free->next; + pool->free = free_pop->next; + pool->totused++; #ifdef WITH_MEM_VALGRIND - VALGRIND_MEMPOOL_ALLOC(pool, retval, pool->esize); + VALGRIND_MEMPOOL_ALLOC(pool, free_pop, pool->esize); #endif - return retval; + return (void *)free_pop; } void *BLI_mempool_calloc(BLI_mempool *pool) |