From ccc2a7996b836cd255fbb7d7f693f5b958442043 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 20 Jul 2020 16:00:20 +0200 Subject: 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. --- source/blender/blenlib/BLI_set.hh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/blenlib/BLI_set.hh') diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh index 80e4858bbb9..90adea69e06 100644 --- a/source/blender/blenlib/BLI_set.hh +++ b/source/blender/blenlib/BLI_set.hh @@ -89,11 +89,8 @@ template< * The minimum number of elements that can be stored in this Set without doing a heap * allocation. This is useful when you expect to have many small sets. However, keep in mind * that (unlike vector) initializing a set has a O(n) cost in the number of slots. - * - * When Key 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(Key) < 100) ? 4 : 0, + int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(Key)), /** * The strategy used to deal with collisions. They are defined in BLI_probing_strategies.hh. */ @@ -821,6 +818,18 @@ template class StdUnorderedSetWrapper { } }; +/** + * Same as a normal Set, but does not use Blender's guarded allocator. This is useful when + * allocating memory with static storage duration. + */ +template, + typename IsEqual = DefaultEquality, + typename Slot = typename DefaultSetSlot::type> +using RawSet = Set; + } // namespace blender #endif /* __BLI_SET_HH__ */ -- cgit v1.2.3