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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-01-26 18:38:18 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-01-27 14:22:01 +0300
commit1107af1abb0d4bf271e995a18f5d4bd790d51d02 (patch)
treea5cc6e1390176cdb62bf40870d4dd5a5b18ee617 /intern/guardedalloc/MEM_guardedalloc.h
parent9cacadc8a637cc6c96380f73c4bfd1d6967351bd (diff)
Fix OBJECT_GUARDED_FREE compiler error when type is in namespace
Diffstat (limited to 'intern/guardedalloc/MEM_guardedalloc.h')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index b1a0eda0e22..958e5ae86cd 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -231,6 +231,10 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
void MEM_use_guarded_allocator(void);
#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
/* alloc funcs for C++ only */
# define MEM_CXX_CLASS_ALLOC_FUNCS(_id) \
public: \
@@ -253,6 +257,13 @@ void MEM_use_guarded_allocator(void);
MEM_freeN(mem); \
}
+/* Needed when type includes a namespace, then the namespace should not be
+ * specified after ~, so using a macro fails. */
+template<class T> inline void OBJECT_GUARDED_DESTRUCTOR(T *what)
+{
+ what->~T();
+}
+
# if defined __GNUC__
# define OBJECT_GUARDED_NEW(type, args...) new (MEM_mallocN(sizeof(type), __func__)) type(args)
# else
@@ -262,15 +273,11 @@ void MEM_use_guarded_allocator(void);
# define OBJECT_GUARDED_DELETE(what, type) \
{ \
if (what) { \
- ((type *)(what))->~type(); \
+ OBJECT_GUARDED_DESTRUCTOR((type *)what); \
MEM_freeN(what); \
} \
} \
(void)0
#endif /* __cplusplus */
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
#endif /* __MEM_GUARDEDALLOC_H__ */