[Bf-blender-cvs] [16c92706d8f] functions: some comments for allocators

Jacques Lucke noreply at git.blender.org
Thu Jul 4 18:05:55 CEST 2019


Commit: 16c92706d8fc0fd11ead259c9284f319e7b9f64f
Author: Jacques Lucke
Date:   Thu Jul 4 17:33:46 2019 +0200
Branches: functions
https://developer.blender.org/rB16c92706d8fc0fd11ead259c9284f319e7b9f64f

some comments for allocators

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

M	source/blender/blenlib/BLI_fixed_array_allocator.hpp
M	source/blender/blenlib/BLI_mempool.hpp

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

diff --git a/source/blender/blenlib/BLI_fixed_array_allocator.hpp b/source/blender/blenlib/BLI_fixed_array_allocator.hpp
index 34fc9f8ac29..810886bba37 100644
--- a/source/blender/blenlib/BLI_fixed_array_allocator.hpp
+++ b/source/blender/blenlib/BLI_fixed_array_allocator.hpp
@@ -1,5 +1,11 @@
 #pragma once
 
+/**
+ * This allocator should be used, when arrays of the same length are often allocated and
+ * deallocated. Knowing that all arrays have the same length makes it possible to just store the
+ * size of a single element to identify the buffer length, which is a small number usually.
+ */
+
 #include "BLI_small_stack.hpp"
 
 namespace BLI {
diff --git a/source/blender/blenlib/BLI_mempool.hpp b/source/blender/blenlib/BLI_mempool.hpp
index 5fa8d92b8aa..9455acf32a6 100644
--- a/source/blender/blenlib/BLI_mempool.hpp
+++ b/source/blender/blenlib/BLI_mempool.hpp
@@ -48,6 +48,10 @@ class MemPool {
     }
   }
 
+  /**
+   * Get a pointer to an uninitialized memory buffer of the size set in the constructor. The buffer
+   * will be invalidated when the MemPool is destroyed.
+   */
   void *allocate()
   {
     if (m_free_stack.empty()) {
@@ -60,6 +64,10 @@ class MemPool {
     return ptr;
   }
 
+  /**
+   * Deallocate a pointer that has been allocated using the same mempool before. The memory won't
+   * actually be freed immediatly.
+   */
   void deallocate(void *ptr)
   {
 #ifdef DEBUG



More information about the Bf-blender-cvs mailing list