Browse Source

no message

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

+ 0
- 2
TestApp1/TestApp1.cpp View File

@@ -4,10 +4,8 @@
4 4
 #ifdef _WIN32
5 5
 #include "Win32/stdafx.h"
6 6
 #endif
7
-
8 7
 #include <DK.h>
9 8
 
10
-
11 9
 class TestApp1 : public DKApplication
12 10
 {
13 11
 	DKObject<DKWindow> window;

+ 1
- 0
TestApp1/TestApp1.vcxproj View File

@@ -187,6 +187,7 @@ xcopy /Y /D /R /Q /E "$(SolutionDir)Data" "$(OutDir)Data\"
187 187
     <ClInclude Include="Win32\targetver.h" />
188 188
   </ItemGroup>
189 189
   <ItemGroup>
190
+    <ClCompile Include="dkgl_new.cpp" />
190 191
     <ClCompile Include="TestApp1.cpp" />
191 192
   </ItemGroup>
192 193
   <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
+}