]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - win/inspircd_memory_functions.cpp
We will get this right eventually
[user/henk/code/inspircd.git] / win / inspircd_memory_functions.cpp
1 // Use the global heap for this process for all allocate/free operations.\r
2 #include "inspircd_win32wrapper.h"\r
3 #include <exception>\r
4 #include <new>\r
5 #include <new.h>\r
6 \r
7 void * ::operator new(size_t iSize)\r
8 {\r
9         void* ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iSize);               // zero memory for unix compatibility\r
10         /* This is the correct behaviour according to C++ standards for out of memory,\r
11          * not returning null -- Brain*/\r
12         if (!ptr)\r
13                 throw std::bad_alloc();\r
14         else\r
15                 return ptr;\r
16 }\r
17 \r
18 void ::operator delete(void * ptr)\r
19 {\r
20         HeapFree(GetProcessHeap(), 0, ptr);\r
21 }\r