Skip to content

Commit 65bf516

Browse files
committed
Fix memnew_placement with char * arguments. Before, it would call the description version, allocating on the heap instead of ni the given memory.
1 parent ab6c6ee commit 65bf516

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/os/memory.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class DefaultAllocator {
9595
_FORCE_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr, false); }
9696
};
9797

98+
// Works around an issue where memnew_placement (char *) would call the p_description version.
99+
inline void *operator new(size_t p_size, char *p_dest) {
100+
return operator new(p_size, (void *)p_dest);
101+
}
98102
void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
99103
void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< operator new that takes a description and uses MemoryStaticPool
100104

0 commit comments

Comments
 (0)