diff options
| author | 2007-05-20 14:08:20 +0000 | |
|---|---|---|
| committer | 2007-05-20 14:08:20 +0000 | |
| commit | 81c9291f4ef984aefd92f28339bd4ed97dfd3e65 (patch) | |
| tree | dfaaac8d4afffe8ae8c492af19dead3b01c78f5f /win/inspircd_memory_functions.cpp | |
| parent | try...catch around the map::insert in AddFd, for some reason it throws someti... (diff) | |
Throw bad alloc on out of memory, not return null, this is the correct behaviour according to the C++ standards
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7066 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'win/inspircd_memory_functions.cpp')
| -rw-r--r-- | win/inspircd_memory_functions.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/win/inspircd_memory_functions.cpp b/win/inspircd_memory_functions.cpp index d03330bf5..7e2f23194 100644 --- a/win/inspircd_memory_functions.cpp +++ b/win/inspircd_memory_functions.cpp @@ -1,9 +1,16 @@ // Use the global heap for this process for all allocate/free operations.
#include "inspircd_win32wrapper.h"
+#include <exception.h>
void * ::operator new(size_t iSize)
{
- return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iSize); // zero memory for unix compatibility
+ void* ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iSize); // zero memory for unix compatibility
+ /* This is the correct behaviour according to C++ standards for out of memory,
+ * not returning null -- Brain*/
+ if (!ptr)
+ throw std::bad_alloc;
+ else
+ return ptr;
}
void ::operator delete(void * ptr)
|
