|
44 | 44 | #define PAD_ALIGN 16 //must always be greater than this at much |
45 | 45 | #endif |
46 | 46 |
|
47 | | -void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool |
48 | | -void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool |
49 | | -void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory |
| 47 | +// p_dummy argument is added to avoid conflicts with the engine functions when both engine and GDExtension are built as a static library on iOS. |
| 48 | +void *operator new(size_t p_size, const char *p_dummy, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool |
| 49 | +void *operator new(size_t p_size, const char *p_dummy, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool |
| 50 | +void *operator new(size_t p_size, const char *p_dummy, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory |
50 | 51 |
|
51 | | -_ALWAYS_INLINE_ void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description) { |
| 52 | +_ALWAYS_INLINE_ void *operator new(size_t p_size, const char *p_dummy, void *p_pointer, size_t check, const char *p_description) { |
52 | 53 | return p_pointer; |
53 | 54 | } |
54 | 55 |
|
55 | 56 | #ifdef _MSC_VER |
56 | 57 | // When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291). |
57 | 58 | // The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete. |
58 | | -void operator delete(void *p_mem, const char *p_description); |
59 | | -void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)); |
60 | | -void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description); |
| 59 | +void operator delete(void *p_mem, const char *p_dummy, const char *p_description); |
| 60 | +void operator delete(void *p_mem, const char *p_dummy, void *(*p_allocfunc)(size_t p_size)); |
| 61 | +void operator delete(void *p_mem, const char *p_dummy, void *p_pointer, size_t check, const char *p_description); |
61 | 62 | #endif |
62 | 63 |
|
63 | 64 | namespace godot { |
@@ -85,10 +86,10 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) { |
85 | 86 | #define memrealloc(m_mem, m_size) ::godot::Memory::realloc_static(m_mem, m_size) |
86 | 87 | #define memfree(m_mem) ::godot::Memory::free_static(m_mem) |
87 | 88 |
|
88 | | -#define memnew(m_class) ::godot::_post_initialize(new ("") m_class) |
| 89 | +#define memnew(m_class) ::godot::_post_initialize(new ("", "") m_class) |
89 | 90 |
|
90 | | -#define memnew_allocator(m_class, m_allocator) ::godot::_post_initialize(new (m_allocator::alloc) m_class) |
91 | | -#define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new (m_placement, sizeof(m_class), "") m_class) |
| 91 | +#define memnew_allocator(m_class, m_allocator) ::godot::_post_initialize(new ("", m_allocator::alloc) m_class) |
| 92 | +#define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new ("", m_placement, sizeof(m_class), "") m_class) |
92 | 93 |
|
93 | 94 | // Generic comparator used in Map, List, etc. |
94 | 95 | template <class T> |
@@ -154,7 +155,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") { |
154 | 155 |
|
155 | 156 | /* call operator new */ |
156 | 157 | for (size_t i = 0; i < p_elements; i++) { |
157 | | -new (&elems[i], sizeof(T), p_descr) T; |
| 158 | +new ("", &elems[i], sizeof(T), p_descr) T; |
158 | 159 | } |
159 | 160 | } |
160 | 161 |
|
|
0 commit comments