From 65bf51600652bddc8faea0f7f6a1ead0e28da81b Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Sat, 25 Oct 2025 17:26:37 +0200 Subject: [PATCH] Fix `memnew_placement` with `char *` arguments. Before, it would call the description version, allocating on the heap instead of ni the given memory. --- core/os/memory.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/os/memory.h b/core/os/memory.h index 17426bb6f4d..2491d64ea48 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -95,6 +95,10 @@ public: _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, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool