-
Notifications
You must be signed in to change notification settings - Fork 661
Expand file tree
/
Copy pathnew.cpp
More file actions
43 lines (36 loc) · 812 Bytes
/
new.cpp
File metadata and controls
43 lines (36 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cstddef> // std::size_t
#include "server.h"
#include "new.h"
#include <new>
#ifdef SANITIZE
void *operator new(size_t size, enum MALLOC_CLASS mclass)
{
(void)mclass;
return ::operator new(size);
}
#else
[[deprecated]]
void *operator new(size_t size)
{
return zmalloc(size, MALLOC_LOCAL);
}
void *operator new(size_t size, enum MALLOC_CLASS mclass)
{
return zmalloc(size, mclass);
}
void *operator new(std::size_t size, const std::nothrow_t &) noexcept
{
return zmalloc(size, MALLOC_LOCAL);
}
//need to do null checks for delete since the compiler can optimize out null checks in zfree
void operator delete(void * p) noexcept
{
if (p != nullptr)
zfree(p);
}
void operator delete(void *p, std::size_t) noexcept
{
if (p != nullptr)
zfree(p);
}
#endif