Core: remove WITH_CXX_GUARDEDALLOC option
This implements the proposal from #124512. For that it contains the following changes: * Remove the global override of `new`/`delete` when `WITH_CXX_GUARDEDALLOC` was enabled. * Always use `MEM_CXX_CLASS_ALLOC_FUNCS` where it is currently used. This used to be guarded by `WITH_CXX_GUARDEDALLOC` in some but not all cases. This means that a few classes which didn't use our guarded allocator by default before, are now using it. Pull Request: https://projects.blender.org/blender/blender/pulls/130181
This commit is contained in:
@@ -63,14 +63,6 @@ endif()
|
||||
blender_add_lib(bf_intern_guardedalloc "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
add_library(bf::intern::guardedalloc ALIAS bf_intern_guardedalloc)
|
||||
|
||||
# Override C++ allocator, optional.
|
||||
if(WITH_CXX_GUARDEDALLOC)
|
||||
set(SRC
|
||||
cpp/mallocn.cpp
|
||||
)
|
||||
blender_add_lib(bf_intern_guardedalloc_cpp "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
endif()
|
||||
|
||||
if(WITH_GTESTS)
|
||||
set(TEST_SRC
|
||||
tests/guardedalloc_alignment_test.cc
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2002-2022 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup intern_mem
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
#include "../intern/mallocn_intern_function_pointers.hh"
|
||||
|
||||
using namespace mem_guarded::internal;
|
||||
|
||||
void *operator new(size_t size, const char *str);
|
||||
void *operator new[](size_t size, const char *str);
|
||||
|
||||
/* not default but can be used when needing to set a string */
|
||||
void *operator new(size_t size, const char *str)
|
||||
{
|
||||
return mem_mallocN_aligned_ex(size, 1, str, AllocationType::NEW_DELETE);
|
||||
}
|
||||
void *operator new[](size_t size, const char *str)
|
||||
{
|
||||
return mem_mallocN_aligned_ex(size, 1, str, AllocationType::NEW_DELETE);
|
||||
}
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return mem_mallocN_aligned_ex(size, 1, "C++/anonymous", AllocationType::NEW_DELETE);
|
||||
}
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return mem_mallocN_aligned_ex(size, 1, "C++/anonymous[]", AllocationType::NEW_DELETE);
|
||||
}
|
||||
|
||||
void operator delete(void *p) throw()
|
||||
{
|
||||
/* `delete nullptr` is valid in c++. */
|
||||
if (p) {
|
||||
mem_freeN_ex(p, AllocationType::NEW_DELETE);
|
||||
}
|
||||
}
|
||||
void operator delete[](void *p) throw()
|
||||
{
|
||||
/* `delete nullptr` is valid in c++. */
|
||||
if (p) {
|
||||
mem_freeN_ex(p, AllocationType::NEW_DELETE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user