Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-10-09 12:46:02 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-10-09 12:46:02 +0400
commit49bc31067163474729755c8a9dbd543ba3744d3f (patch)
treef827273ee51caa8f7bf136f749b6bd4ac9f3dca2 /intern/guardedalloc/MEM_guardedalloc.h
parent22a30f78f2d7928095d8158f3c54d726771ba24d (diff)
Move guarded objetc allocation to a guardedalloc header
Also made libmv-capi use guarded objetc allocation. Run into some suspecious cases when it was not so clear whether memory is being freed or not. Now we'll know for sure whether there're leaks or not :) Having this macros in a guardedalloc header helps using them in other areas (for now it's OCIO and libmv, but in the future it'll be more places).
Diffstat (limited to 'intern/guardedalloc/MEM_guardedalloc.h')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index d5ba2f5bd68..aebde0a6425 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -244,6 +244,24 @@ public: \
MEM_freeN(mem); \
} \
+#if defined __GNUC__ || defined __sun
+# define OBJECT_GUARDED_NEW(type, args ...) \
+ new(MEM_mallocN(sizeof(type), __func__)) type(args)
+#else
+# define OBJECT_GUARDED_NEW(type, ...) \
+ new(MEM_mallocN(sizeof(type), __FUNCTION__)) type(__VA_ARGS__)
+#endif
+#define OBJECT_GUARDED_DELETE(what, type) \
+ { if(what) { \
+ ((type*)(what))->~type(); \
+ MEM_freeN(what); \
+ } } (void)0
+#define OBJECT_GUARDED_DELETE_ARRAY(what, type, count) \
+ { if(what) { \
+ for (int i = 0; i < count; i++) ((type*)(what))[i].~type(); \
+ MEM_freeN(what); \
+ } } (void)0
+
#endif /* __cplusplus */
#ifdef __cplusplus