[Bf-blender-cvs] [e485f030e8d] functions: fix temporary deallocation

Jacques Lucke noreply at git.blender.org
Mon Sep 2 12:32:08 CEST 2019


Commit: e485f030e8d338da92fc267849959e053c86c3b5
Author: Jacques Lucke
Date:   Mon Sep 2 12:05:16 2019 +0200
Branches: functions
https://developer.blender.org/rBe485f030e8d338da92fc267849959e053c86c3b5

fix temporary deallocation

===================================================================

M	source/blender/blenlib/intern/BLI_temporary_allocator.cpp

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_temporary_allocator.cpp b/source/blender/blenlib/intern/BLI_temporary_allocator.cpp
index 03260b95255..87c415663ff 100644
--- a/source/blender/blenlib/intern/BLI_temporary_allocator.cpp
+++ b/source/blender/blenlib/intern/BLI_temporary_allocator.cpp
@@ -26,19 +26,6 @@ constexpr uint ALIGNMENT = BLI_TEMPORARY_BUFFER_ALIGNMENT;
 constexpr uint SMALL_BUFFER_SIZE = 64 * 1024;
 constexpr uintptr_t ALIGNMENT_MASK = ~(uintptr_t)(ALIGNMENT - 1);
 
-struct ThreadLocalBuffers {
-  Stack<void *, 32, RawAllocator> buffers;
-
-  ~ThreadLocalBuffers()
-  {
-    for (void *ptr : buffers) {
-      RawAllocator().deallocate(ptr);
-    }
-  }
-};
-
-thread_local ThreadLocalBuffers local_storage;
-
 enum TemporaryBufferType {
   Small,
   Large,
@@ -74,6 +61,19 @@ static void raw_deallocate(void *ptr)
   free(raw_ptr);
 }
 
+struct ThreadLocalBuffers {
+  Stack<void *, 32, RawAllocator> buffers;
+
+  ~ThreadLocalBuffers()
+  {
+    for (void *ptr : buffers) {
+      raw_deallocate(ptr);
+    }
+  }
+};
+
+thread_local ThreadLocalBuffers local_storage;
+
 void *BLI_temporary_allocate(uint size)
 {
   if (size <= SMALL_BUFFER_SIZE) {



More information about the Bf-blender-cvs mailing list