[Bf-blender-cvs] [0387abd20fa] functions: better explanation for lazy-init macros

Jacques Lucke noreply at git.blender.org
Wed Jun 5 10:07:24 CEST 2019


Commit: 0387abd20fae495b0edeb71f12910e755be0f0a5
Author: Jacques Lucke
Date:   Wed Jun 5 10:05:27 2019 +0200
Branches: functions
https://developer.blender.org/rB0387abd20fae495b0edeb71f12910e755be0f0a5

better explanation for lazy-init macros

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

M	source/blender/blenlib/BLI_lazy_init.hpp

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

diff --git a/source/blender/blenlib/BLI_lazy_init.hpp b/source/blender/blenlib/BLI_lazy_init.hpp
index 026f7437001..fae51f824e5 100644
--- a/source/blender/blenlib/BLI_lazy_init.hpp
+++ b/source/blender/blenlib/BLI_lazy_init.hpp
@@ -1,7 +1,17 @@
 #pragma once
 
-/* These macros help to define functions that initialize
- * some data the first time it is used. */
+/* These macros help to define functions that should only be
+ * executed once to initialize some data. The initialized data
+ * will only be freed when Blender quits.
+ *
+ * Requirements:
+ *   - Very simple usage, without exposing the implementation details.
+ *   - No additional heap allocation for every lazy initialized piece of data.
+ *   - Blender has to be able to free all lazy-initialized data shortly
+ *     before it quits. This is to make Blenders leak detection not detect
+ *     false positives. It would, when we would just depend on static variables.
+ *     These are destructed, after Blender prints non-freed memory blocks.
+ */
 
 #include <functional>
 #include <BLI_optional.hpp>



More information about the Bf-blender-cvs mailing list