diff options
Diffstat (limited to 'CPP/Common/NewHandler.cpp')
-rw-r--r-- | CPP/Common/NewHandler.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/CPP/Common/NewHandler.cpp b/CPP/Common/NewHandler.cpp index c95833e..173b8eb 100644 --- a/CPP/Common/NewHandler.cpp +++ b/CPP/Common/NewHandler.cpp | |||
@@ -65,6 +65,13 @@ operator new(size_t size) | |||
65 | return p; | 65 | return p; |
66 | } | 66 | } |
67 | 67 | ||
68 | |||
69 | #if defined(_MSC_VER) && _MSC_VER == 1600 | ||
70 | // vs2010 has no throw() by default ? | ||
71 | #pragma warning(push) | ||
72 | #pragma warning(disable : 4986) // 'operator delete': exception specification does not match previous declaration | ||
73 | #endif | ||
74 | |||
68 | void | 75 | void |
69 | #ifdef _MSC_VER | 76 | #ifdef _MSC_VER |
70 | __cdecl | 77 | __cdecl |
@@ -76,6 +83,27 @@ operator delete(void *p) throw() | |||
76 | ::free(p); | 83 | ::free(p); |
77 | } | 84 | } |
78 | 85 | ||
86 | /* we define operator delete(void *p, size_t n) because | ||
87 | vs2022 compiler uses delete(void *p, size_t n), and | ||
88 | we want to mix files from different compilers: | ||
89 | - old vc6 linker | ||
90 | - old vc6 complier | ||
91 | - new vs2022 complier | ||
92 | */ | ||
93 | void | ||
94 | #ifdef _MSC_VER | ||
95 | __cdecl | ||
96 | #endif | ||
97 | operator delete(void *p, size_t n) throw() | ||
98 | { | ||
99 | UNUSED_VAR(n) | ||
100 | ::free(p); | ||
101 | } | ||
102 | |||
103 | #if defined(_MSC_VER) && _MSC_VER == 1600 | ||
104 | #pragma warning(pop) | ||
105 | #endif | ||
106 | |||
79 | /* | 107 | /* |
80 | void * | 108 | void * |
81 | #ifdef _MSC_VER | 109 | #ifdef _MSC_VER |
@@ -205,11 +233,9 @@ operator delete(void *p) throw() | |||
205 | a[i] = 0; | 233 | a[i] = 0; |
206 | */ | 234 | */ |
207 | HeapFree(GetProcessHeap(), 0, p); | 235 | HeapFree(GetProcessHeap(), 0, p); |
208 | if (numAllocs == 0) | 236 | // if (numAllocs == 0) numAllocs = numAllocs; // ERROR |
209 | numAllocs = numAllocs; // ERROR | ||
210 | numAllocs--; | 237 | numAllocs--; |
211 | if (numAllocs == 0) | 238 | // if (numAllocs == 0) numAllocs = numAllocs; // OK: all objects were deleted |
212 | numAllocs = numAllocs; // OK: all objects were deleted | ||
213 | printf("Free %d\n", numAllocs); | 239 | printf("Free %d\n", numAllocs); |
214 | LeaveCriticalSection(&cs); | 240 | LeaveCriticalSection(&cs); |
215 | #else | 241 | #else |
@@ -219,6 +245,22 @@ operator delete(void *p) throw() | |||
219 | #endif | 245 | #endif |
220 | } | 246 | } |
221 | 247 | ||
248 | void | ||
249 | #ifdef _MSC_VER | ||
250 | __cdecl | ||
251 | #endif | ||
252 | operator delete(void *p, size_t n) throw(); | ||
253 | void | ||
254 | #ifdef _MSC_VER | ||
255 | __cdecl | ||
256 | #endif | ||
257 | operator delete(void *p, size_t n) throw() | ||
258 | { | ||
259 | UNUSED_VAR(n) | ||
260 | printf("delete_WITH_SIZE=%u, ptr = %p\n", (unsigned)n, p); | ||
261 | operator delete(p); | ||
262 | } | ||
263 | |||
222 | /* | 264 | /* |
223 | void * | 265 | void * |
224 | #ifdef _MSC_VER | 266 | #ifdef _MSC_VER |