Fix OBJECT_GUARDED_FREE compiler error when type is in namespace

This commit is contained in:
2020-01-26 16:38:18 +01:00
parent 9cacadc8a6
commit 1107af1abb
40 changed files with 75 additions and 60 deletions

View File

@@ -230,6 +230,10 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
/* Switch allocator to slower but fully guarded mode. */
void MEM_use_guarded_allocator(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#ifdef __cplusplus
/* alloc funcs for C++ only */
# define MEM_CXX_CLASS_ALLOC_FUNCS(_id) \
@@ -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__ */

View File

@@ -28,9 +28,9 @@
#include "abc_transform.h"
#include "abc_util.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_curve_types.h"
#include "DNA_object_types.h"

View File

@@ -25,9 +25,9 @@
#include "abc_transform.h"
#include "abc_util.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"

View File

@@ -22,6 +22,8 @@
#include "abc_mesh.h"
#include "abc_transform.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_meta_types.h"
#include "DNA_mesh_types.h"
@@ -35,7 +37,6 @@ extern "C" {
#include "BKE_object.h"
#include "DEG_depsgraph.h"
#include "MEM_guardedalloc.h"
}
AbcMBallWriter::AbcMBallWriter(Main *bmain,

View File

@@ -25,6 +25,8 @@
#include "abc_transform.h"
#include "abc_util.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
@@ -46,8 +48,6 @@ extern "C" {
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"

View File

@@ -23,9 +23,9 @@
#include "abc_transform.h"
#include "abc_util.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_curve_types.h"
#include "DNA_object_types.h"

View File

@@ -32,9 +32,9 @@
#include "abc_transform.h"
#include "abc_util.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_cachefile_types.h"
#include "DNA_curve_types.h"
#include "DNA_modifier_types.h"

View File

@@ -23,8 +23,9 @@
#include "collada_utils.h"
#include "BCSampleData.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "BKE_fcurve.h"
#include "BKE_armature.h"
#include "BKE_material.h"

View File

@@ -56,6 +56,8 @@
#include "COLLADASWInstanceNode.h"
#include "COLLADASWBaseInputElement.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -99,8 +101,6 @@ extern char build_commit_time[];
extern char build_hash[];
#endif
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
}

View File

@@ -43,6 +43,8 @@
#include "COLLADASaxFWLLoader.h"
#include "COLLADASaxFWLIExtraDataCallbackHandler.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -68,8 +70,6 @@ extern "C" {
#include "RNA_access.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"
}

View File

@@ -31,6 +31,8 @@
#include "COLLADAFWMeshVertexData.h"
#include "COLLADAFWPolygons.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BKE_customdata.h"
#include "BKE_displist.h"
@@ -44,8 +46,6 @@ extern "C" {
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_edgehash.h"
#include "MEM_guardedalloc.h"
}
#include "ArmatureImporter.h"

View File

@@ -27,6 +27,9 @@
#include <set>
#include <string>
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_modifier_types.h"
#include "DNA_customdata_types.h"
@@ -62,8 +65,6 @@ extern "C" {
#include "ED_node.h"
#include "ED_object.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h" /* XXX hrm, see if we can do without this */
#include "WM_types.h"

View File

@@ -17,6 +17,7 @@
*/
#include "COM_CompositorOperation.h"
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -26,7 +27,6 @@ extern "C" {
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
#include "RE_render_ext.h"
#include "MEM_guardedalloc.h"
#include "render_types.h"
}
#include "PIL_time.h"

View File

@@ -20,13 +20,13 @@
#define __COM_IMAGEOPERATION_H__
#include "COM_NodeOperation.h"
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
extern "C" {
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
#include "RE_render_ext.h"
#include "MEM_guardedalloc.h"
}
/**

View File

@@ -30,9 +30,9 @@
#include "BKE_scene.h"
#include "DNA_color_types.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"

View File

@@ -26,8 +26,8 @@
#include "BLI_math_color.h"
#include "COM_defines.h"
#include "BLI_math.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"

View File

@@ -20,12 +20,12 @@
#define __COM_RENDERLAYERSPROG_H__
#include "COM_NodeOperation.h"
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BKE_image.h"
extern "C" {
#include "RE_pipeline.h"
#include "MEM_guardedalloc.h"
}
/**

View File

@@ -22,9 +22,9 @@
#include "BLI_utildefines.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
}

View File

@@ -22,11 +22,11 @@
#include "COM_NodeOperation.h"
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
#include "RE_render_ext.h"
#include "MEM_guardedalloc.h"
}
/**

View File

@@ -26,9 +26,9 @@
#include "BLI_utildefines.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"

View File

@@ -35,9 +35,9 @@
#include "../system/FreestyleConfig.h"
#include "../system/RenderMonitor.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"

View File

@@ -23,9 +23,9 @@
#include "../application/AppConfig.h"
#include "../stroke/Canvas.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "RNA_access.h"
#include "RNA_types.h"

View File

@@ -32,10 +32,10 @@
using namespace std;
using namespace Freestyle;
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_camera_types.h"
#include "DNA_collection_types.h"
#include "DNA_freestyle_types.h"

View File

@@ -31,10 +31,10 @@ extern "C" {
#include "StringUtils.h"
#include "Interpreter.h"
// soc
extern "C" {
#include "MEM_guardedalloc.h"
// soc
extern "C" {
#include "DNA_text_types.h"
#include "BKE_context.h"

View File

@@ -33,9 +33,9 @@
#include "openimageio_api.h"
#include <OpenImageIO/imageio.h>
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_blenlib.h"
#include "IMB_imbuf_types.h"

View File

@@ -65,6 +65,8 @@
# include "utfconv.h"
#endif
#include "MEM_guardedalloc.h"
extern "C" {
// The following prevents a linking error in debug mode for MSVC using the libs in CVS
@@ -74,8 +76,6 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
}
#endif
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
#include "BLI_threads.h"

View File

@@ -21,9 +21,9 @@
* \ingroup bph
*/
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "DNA_cloth_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_force_types.h"

View File

@@ -23,6 +23,8 @@
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/tokens.h>
#include "MEM_guardedalloc.h"
extern "C" {
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -39,8 +41,6 @@ extern "C" {
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"
}

View File

@@ -2,10 +2,10 @@
#include "testing/testing.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_array_store.h"
#include "MEM_guardedalloc.h"
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"

View File

@@ -2,8 +2,9 @@
#include "testing/testing.h"
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_math.h"
#include "BLI_rand.h"
#include "PIL_time.h"

View File

@@ -5,8 +5,9 @@
#define GHASH_INTERNAL_API
extern "C" {
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_rand.h"

View File

@@ -3,14 +3,14 @@
#include "testing/testing.h"
#include <string.h>
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_sys_types.h"
#include "BLI_compiler_attrs.h"
#include "BLI_heap_simple.h"
#include "BLI_utildefines.h"
#include "BLI_rand.h"
#include "MEM_guardedalloc.h"
};
#define SIZE 1024

View File

@@ -3,13 +3,13 @@
#include "testing/testing.h"
#include <string.h>
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_compiler_attrs.h"
#include "BLI_heap.h"
#include "BLI_utildefines.h"
#include "BLI_rand.h"
#include "MEM_guardedalloc.h"
};
#define SIZE 1024

View File

@@ -4,12 +4,13 @@
/* TODO: ray intersection, overlap ... etc.*/
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_compiler_attrs.h"
#include "BLI_kdopbvh.h"
#include "BLI_rand.h"
#include "BLI_math_vector.h"
#include "MEM_guardedalloc.h"
}
#include "stubs/bf_intern_eigen_stubs.h"

View File

@@ -2,11 +2,11 @@
#include "testing/testing.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_array_utils.h"
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
#include "BLI_path_util.h"
#include "BLI_ressource_strings.h"

View File

@@ -2,10 +2,11 @@
#include "testing/testing.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_array_utils.h"
#include "BLI_memiter.h"
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
#include "BLI_ressource_strings.h"

View File

@@ -9,13 +9,14 @@
#define USE_COMBINATIONS_ALL
#define USE_BEAUTIFY
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_utildefines.h"
#include "BLI_array_utils.h"
#include "BLI_polyfill_2d.h"
#include "BLI_edgehash.h"
#include "BLI_math.h"
#include "MEM_guardedalloc.h"
#ifdef USE_OBJ_PREVIEW
# include "BLI_string.h"

View File

@@ -7,6 +7,8 @@
#define GHASH_INTERNAL_API
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_utildefines.h"
@@ -15,8 +17,6 @@ extern "C" {
#include "BLI_task.h"
#include "PIL_time.h"
#include "MEM_guardedalloc.h"
}
#define NUM_RUN_AVERAGED 100

View File

@@ -5,14 +5,14 @@
#include "atomic_ops.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_task.h"
#include "MEM_guardedalloc.h"
};
#define NUM_ITEMS 10000

View File

@@ -17,6 +17,8 @@
*/
#include "blendfile_loading_base_test.h"
#include "MEM_guardedalloc.h"
extern "C" {
#include "BKE_appdir.h"
#include "BKE_blender.h"
@@ -41,8 +43,6 @@ extern "C" {
#include "IMB_imbuf.h"
#include "MEM_guardedalloc.h"
#include "RNA_define.h"
#include "WM_api.h"