diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-23 19:35:16 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-27 14:22:01 +0300 |
commit | c76a8f65b7e5f65b8c10b2d3b574c90ebc3d01c0 (patch) | |
tree | 8594ee28a6ee242488ee22955ddc0ebd8612f44f | |
parent | 1107af1abb0d4bf271e995a18f5d4bd790d51d02 (diff) |
Memory: add OBJECT_GUARDED_SAFE_DELETE like MEM_SAFE_FREE
-rw-r--r-- | intern/guardedalloc/MEM_guardedalloc.h | 9 |
1 files changed, 9 insertions, 0 deletions
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__ */ |