diff options
Diffstat (limited to 'source/blender/blenlib/BLI_memarena.h')
-rw-r--r-- | source/blender/blenlib/BLI_memarena.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index b2e05b00735..4ac4712bc8c 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -29,8 +29,8 @@ extern "C" { #endif -/* A reasonable standard buffer size, big - * enough to not cause much internal fragmentation, +/** + * A reasonable standard buffer size, big enough to not cause much internal fragmentation, * small enough not to waste resources */ #define BLI_MEMARENA_STD_BUFSIZE MEM_SIZE_OPTIMAL(1 << 14) @@ -50,8 +50,22 @@ void *BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESU void *BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2); +/** + * Transfer ownership of allocated blocks from `ma_src` into `ma_dst`, + * cleaning the contents of `ma_src`. + * + * \note Useful for multi-threaded tasks that need a thread-local #MemArena + * that is kept after the multi-threaded operation is completed. + * + * \note Avoid accumulating memory pools where possible + * as any unused memory in `ma_src` is wasted every merge. + */ void BLI_memarena_merge(MemArena *ma_dst, MemArena *ma_src) ATTR_NONNULL(1, 2); +/** + * Clear for reuse, avoids re-allocation when an arena may + * otherwise be free'd and recreated. + */ void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1); #ifdef __cplusplus |