|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
|
2
|
+#include <DK.h>
|
|
3
|
+
|
|
4
|
+void* operator new (std::size_t size)
|
|
5
|
+{
|
|
6
|
+ if (size == 0)
|
|
7
|
+ size = 1;
|
|
8
|
+ void* p = nullptr;
|
|
9
|
+ while ((p = DKFoundation::DKMalloc(size)) == nullptr)
|
|
10
|
+ {
|
|
11
|
+ std::new_handler handler = std::get_new_handler();
|
|
12
|
+ if (handler)
|
|
13
|
+ handler();
|
|
14
|
+ else
|
|
15
|
+ throw std::bad_alloc();
|
|
16
|
+ }
|
|
17
|
+ return p;
|
|
18
|
+}
|
|
19
|
+
|
|
20
|
+void* operator new(size_t size, const std::nothrow_t&) noexcept
|
|
21
|
+{
|
|
22
|
+ void* p = nullptr;
|
|
23
|
+ try
|
|
24
|
+ {
|
|
25
|
+ p = ::operator new(size);
|
|
26
|
+ }
|
|
27
|
+ catch (...) {}
|
|
28
|
+ return p;
|
|
29
|
+}
|
|
30
|
+
|
|
31
|
+void* operator new[](std::size_t size)
|
|
32
|
+{
|
|
33
|
+ return ::operator new(size);
|
|
34
|
+}
|
|
35
|
+
|
|
36
|
+void operator delete (void* ptr) noexcept
|
|
37
|
+{
|
|
38
|
+ if (ptr)
|
|
39
|
+ DKFoundation::DKFree(ptr);
|
|
40
|
+}
|
|
41
|
+
|
|
42
|
+void operator delete (void* ptr, const std::nothrow_t&) noexcept
|
|
43
|
+{
|
|
44
|
+ ::operator delete(ptr);
|
|
45
|
+}
|
|
46
|
+
|
|
47
|
+void operator delete[](void* ptr) noexcept
|
|
48
|
+{
|
|
49
|
+ ::operator delete(ptr);
|
|
50
|
+}
|
|
51
|
+
|
|
52
|
+void operator delete[](void* ptr, const std::nothrow_t&) noexcept
|
|
53
|
+{
|
|
54
|
+ ::operator delete(ptr);
|
|
55
|
+}
|