[Bf-blender-cvs] [d46ac7934ab] functions: add utility to debug allocated amount in monotonic allocator
Jacques Lucke
noreply at git.blender.org
Sat Jan 18 20:17:35 CET 2020
Commit: d46ac7934ab161b24de247a44ad5ed87c8fb2797
Author: Jacques Lucke
Date: Sat Jan 11 15:56:37 2020 +0100
Branches: functions
https://developer.blender.org/rBd46ac7934ab161b24de247a44ad5ed87c8fb2797
add utility to debug allocated amount in monotonic allocator
===================================================================
M source/blender/blenlib/BLI_monotonic_allocator.h
===================================================================
diff --git a/source/blender/blenlib/BLI_monotonic_allocator.h b/source/blender/blenlib/BLI_monotonic_allocator.h
index 5627912f985..552e27b7b63 100644
--- a/source/blender/blenlib/BLI_monotonic_allocator.h
+++ b/source/blender/blenlib/BLI_monotonic_allocator.h
@@ -43,6 +43,10 @@ class MonotonicAllocator : NonCopyable, NonMovable {
AlignedBuffer<N, 8> m_inline_buffer;
+#ifdef DEBUG
+ uint m_debug_allocated_amount = 0;
+#endif
+
public:
MonotonicAllocator() : m_remaining_capacity(N), m_next_min_alloc_size(std::max<uint>(N * 2, 16))
{
@@ -71,6 +75,10 @@ class MonotonicAllocator : NonCopyable, NonMovable {
BLI_assert(alignment >= 1);
BLI_assert(is_power_of_2_i(alignment));
+#ifdef DEBUG
+ m_debug_allocated_amount += size;
+#endif
+
uintptr_t alignment_mask = alignment - 1;
uintptr_t current_buffer = (uintptr_t)m_current_buffer;
More information about the Bf-blender-cvs
mailing list