Browse Source

no message

Hongtae Kim 6 years ago
parent
commit
dacc230273
3 changed files with 57 additions and 0 deletions
  1. 1
    0
      TestApp1/TestApp1.vcxproj
  2. 1
    0
      TestApp1/TestApp1.vcxproj.filters
  3. 55
    0
      TestApp1/dkgl_new.cpp

+ 1
- 0
TestApp1/TestApp1.vcxproj View File

@@ -167,6 +167,7 @@
167 167
     <ClInclude Include="Win32\targetver.h" />
168 168
   </ItemGroup>
169 169
   <ItemGroup>
170
+    <ClCompile Include="dkgl_new.cpp" />
170 171
     <ClCompile Include="TestApp1.cpp" />
171 172
   </ItemGroup>
172 173
   <ItemGroup>

+ 1
- 0
TestApp1/TestApp1.vcxproj.filters View File

@@ -31,5 +31,6 @@
31 31
   </ItemGroup>
32 32
   <ItemGroup>
33 33
     <ClCompile Include="TestApp1.cpp" />
34
+    <ClCompile Include="dkgl_new.cpp" />
34 35
   </ItemGroup>
35 36
 </Project>

+ 55
- 0
TestApp1/dkgl_new.cpp View File

@@ -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
+}