[Bf-blender-cvs] [c76a8f65b7e] master: Memory: add OBJECT_GUARDED_SAFE_DELETE like MEM_SAFE_FREE

Brecht Van Lommel noreply at git.blender.org
Mon Jan 27 12:26:09 CET 2020


Commit: c76a8f65b7e5f65b8c10b2d3b574c90ebc3d01c0
Author: Brecht Van Lommel
Date:   Thu Jan 23 17:35:16 2020 +0100
Branches: master
https://developer.blender.org/rBc76a8f65b7e5f65b8c10b2d3b574c90ebc3d01c0

Memory: add OBJECT_GUARDED_SAFE_DELETE like MEM_SAFE_FREE

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

M	intern/guardedalloc/MEM_guardedalloc.h

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

diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 958e5ae86cd..2a4ae5355a0 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -278,6 +278,15 @@ template<class T> inline void OBJECT_GUARDED_DESTRUCTOR(T *what)
       } \
     } \
     (void)0
+#  define OBJECT_GUARDED_SAFE_DELETE(what, type) \
+    { \
+      if (what) { \
+        OBJECT_GUARDED_DESTRUCTOR((type *)what); \
+        MEM_freeN(what); \
+        what = NULL; \
+      } \
+    } \
+    (void)0
 #endif /* __cplusplus */
 
 #endif /* __MEM_GUARDEDALLOC_H__ */



More information about the Bf-blender-cvs mailing list