Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-20 17:00:20 +0300
committerJacques Lucke <jacques@blender.org>2020-07-20 17:03:14 +0300
commitccc2a7996b836cd255fbb7d7f693f5b958442043 (patch)
tree0ce38fb1d1d0980dc73fa6d8816f7f4e82ba46df /source/blender/blenlib/BLI_memory_utils.hh
parented184050b6e787bbfb218e8ad2a0108172a1b68c (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_memory_utils.hh')
-rw-r--r--source/blender/blenlib/BLI_memory_utils.hh9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index 5c692850017..9f65fe0742e 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -419,6 +419,15 @@ template<typename From, typename To>
inline constexpr bool is_convertible_pointer_v =
std::is_convertible_v<From, To> &&std::is_pointer_v<From> &&std::is_pointer_v<To>;
+/**
+ * Inline buffers for small-object-optimization should be disable by default. Otherwise we might
+ * get large unexpected allocations on the stack.
+ */
+inline constexpr int64_t default_inline_buffer_capacity(size_t element_size)
+{
+ return ((int64_t)element_size < 100) ? 4 : 0;
+}
+
} // namespace blender
#endif /* __BLI_MEMORY_UTILS_HH__ */