diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_mempool.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_mempool.c | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index a706e5f3874..8b31459dd38 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -36,7 +36,9 @@ typedef struct BLI_mempool BLI_mempool; BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk); void *BLI_mempool_alloc(BLI_mempool *pool); +void *BLI_mempool_calloc(BLI_mempool *pool); void BLI_mempool_free(BLI_mempool *pool, void *addr); void BLI_mempool_destroy(BLI_mempool *pool); -#endif
\ No newline at end of file + +#endif diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 7bbf0c4732e..7ac7b8b1791 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -89,7 +89,6 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk) curnode->next = NULL; return pool; } - void *BLI_mempool_alloc(BLI_mempool *pool){ void *retval=NULL; BLI_freenode *curnode=NULL; @@ -117,6 +116,16 @@ void *BLI_mempool_alloc(BLI_mempool *pool){ //memset(retval, 0, pool->esize); return retval; } + +void *BLI_mempool_calloc(BLI_mempool *pool){ + void *retval=NULL; + retval = BLI_mempool_alloc(pool); + memset(retval, 0, pool->esize); + return retval; +} + + + void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid! BLI_freenode *newhead = addr; newhead->next = pool->free; @@ -128,4 +137,4 @@ void BLI_mempool_destroy(BLI_mempool *pool) for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) MEM_freeN(mpchunk->data); BLI_freelistN(&(pool->chunks)); MEM_freeN(pool); -}
\ No newline at end of file +} |