Bläddra i källkod

Fix `memnew_placement` with `char *` arguments. Before, it would call the description version, allocating on the heap instead of ni the given memory.

Lukas Tenbrink 1 dag sedan
förälder
incheckning
65bf516006
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      core/os/memory.h

+ 4 - 0
core/os/memory.h

@@ -95,6 +95,10 @@ public:
 	_FORCE_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr, false); }
 	_FORCE_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr, false); }
 };
 };
 
 
+// Works around an issue where memnew_placement (char *) would call the p_description version.
+inline void *operator new(size_t p_size, char *p_dest) {
+	return operator new(p_size, (void *)p_dest);
+}
 void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
 void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
 void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool
 void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool