Blender V4.3
mallocn.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2002-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstddef>
10#include <new>
11
13
14using namespace mem_guarded::internal;
15
16void *operator new(size_t size, const char *str);
17void *operator new[](size_t size, const char *str);
18
19/* not default but can be used when needing to set a string */
20void *operator new(size_t size, const char *str)
21{
22 return mem_mallocN_aligned_ex(size, 1, str, AllocationType::NEW_DELETE);
23}
24void *operator new[](size_t size, const char *str)
25{
26 return mem_mallocN_aligned_ex(size, 1, str, AllocationType::NEW_DELETE);
27}
28
29void *operator new(size_t size)
30{
31 return mem_mallocN_aligned_ex(size, 1, "C++/anonymous", AllocationType::NEW_DELETE);
32}
33void *operator new[](size_t size)
34{
35 return mem_mallocN_aligned_ex(size, 1, "C++/anonymous[]", AllocationType::NEW_DELETE);
36}
37
38void operator delete(void *p) throw()
39{
40 /* `delete nullptr` is valid in c++. */
41 if (p) {
42 mem_freeN_ex(p, AllocationType::NEW_DELETE);
43 }
44}
45void operator delete[](void *p) throw()
46{
47 /* `delete nullptr` is valid in c++. */
48 if (p) {
49 mem_freeN_ex(p, AllocationType::NEW_DELETE);
50 }
51}
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define str(s)
void(* mem_freeN_ex)(void *vmemh, AllocationType allocation_type)
Definition mallocn.cc:37
void *(* mem_mallocN_aligned_ex)(size_t len, size_t alignment, const char *str, AllocationType allocation_type)
Definition mallocn.cc:46