diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-16 23:31:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-16 23:31:42 +0400 |
commit | 3dcc9aef9685388255d4cf9d646830d573aeb932 (patch) | |
tree | 0195d2ad7b887e4a35eda5c94aef9ad54f6e8b39 /source/blender/blenlib/BLI_mempool.h | |
parent | 9b17d39ce031cb89a3e4ea8cbdd0bceb4612871d (diff) |
merge mempool changes from bmesh (adds mempool iterator).
Diffstat (limited to 'source/blender/blenlib/BLI_mempool.h')
-rw-r--r-- | source/blender/blenlib/BLI_mempool.h | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index 2a81966986f..f98919fadd3 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -34,12 +34,45 @@ * \brief Simple fast memory allocator. */ +#ifdef __cplusplus +extern "C" +{ +#endif + struct BLI_mempool; +struct BLI_mempool_chunk; + +typedef struct BLI_mempool BLI_mempool; + +/*allow_iter allows iteration on this mempool. note: this requires that the + first four bytes of the elements never contain the character string + 'free'. use with care.*/ -struct BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc); -void *BLI_mempool_alloc(struct BLI_mempool *pool); -void *BLI_mempool_calloc(struct BLI_mempool *pool); -void BLI_mempool_free(struct BLI_mempool *pool, void *addr); -void BLI_mempool_destroy(struct BLI_mempool *pool); +BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, + short use_sysmalloc, short allow_iter); +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); +int BLI_mempool_count(BLI_mempool *pool); + +/** iteration stuff. note: this may easy to produce bugs with **/ +/*private structure*/ +typedef struct BLI_mempool_iter { + BLI_mempool *pool; + struct BLI_mempool_chunk *curchunk; + int curindex; +} BLI_mempool_iter; + +/*allow iteration on this mempool. note: this requires that the + first four bytes of the elements never contain the character string + 'free'. use with care.*/ +void BLI_mempool_allow_iter(BLI_mempool *pool); +void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter); +void *BLI_mempool_iterstep(BLI_mempool_iter *iter); + +#ifdef __cplusplus +} +#endif #endif |