diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-20 17:00:20 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-20 17:03:14 +0300 |
commit | ccc2a7996b836cd255fbb7d7f693f5b958442043 (patch) | |
tree | 0ce38fb1d1d0980dc73fa6d8816f7f4e82ba46df /source/blender/blenlib/BLI_array.hh | |
parent | ed184050b6e787bbfb218e8ad2a0108172a1b68c (diff) |
BLI: add typedefs for containers that use raw allocators
Those are useful when you have to create containers with static
storage duration. If those would use Blender's guarded allocator,
it would report memory leaks, that are not actually leaks.
Diffstat (limited to 'source/blender/blenlib/BLI_array.hh')
-rw-r--r-- | source/blender/blenlib/BLI_array.hh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index 871038d7d85..c7b4bdc977f 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -53,11 +53,8 @@ template< typename T, /** * The number of values that can be stored in the array, without doing a heap allocation. - * - * When T is large, the small buffer optimization is disabled by default to avoid large - * unexpected allocations on the stack. It can still be enabled explicitly though. */ - int64_t InlineBufferCapacity = (sizeof(T) < 100) ? 4 : 0, + int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), /** * The allocator used by this array. Should rarely be changed, except when you don't want that * MEM_* functions are used internally. @@ -364,6 +361,13 @@ class Array { } }; +/** + * Same as a normal Array, but does not use Blender's guarded allocator. This is useful when + * allocating memory with static storage duration. + */ +template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T))> +using RawArray = Array<T, InlineBufferCapacity, RawAllocator>; + } // namespace blender #endif /* __BLI_ARRAY_HH__ */ |