Fixed wrong memory management with new

This commit is contained in:
llsth 2015-04-11 23:52:57 +02:00
parent 37d2ba4794
commit 2adc0edd4c
2 changed files with 22 additions and 23 deletions

View File

@ -43,29 +43,6 @@
#define Debug(x,y,z,w)
#endif
#ifdef __cplusplus
#if (__GNUC__ > 2)
#include <new>
void* operator new (size_t size) throw(std::bad_alloc) {
return AllocMemSafe(size);
}
void* operator new[] (size_t size) throw(std::bad_alloc) {
return AllocMemSafe(size);
}
void operator delete (void* ptr) throw() {
FreeMemSafe(ptr);
}
void operator delete[] (void* ptr) throw() {
FreeMemSafe(ptr);
}
#else
#endif
#endif
struct MemoryBlock
{
struct MemoryBlock *next;

View File

@ -148,6 +148,28 @@ inline void operator delete[] (void* ptr) {
#endif
#endif
#ifdef __cplusplus
#if (__GNUC__ > 2)
#include <new>
inline void* operator new (size_t size) throw(std::bad_alloc) {
return AllocMemSafe(size);
}
inline void* operator new[] (size_t size) throw(std::bad_alloc) {
return AllocMemSafe(size);
}
inline void operator delete (void* ptr) throw() {
FreeMemSafe(ptr);
}
inline void operator delete[] (void* ptr) throw() {
FreeMemSafe(ptr);
}
#endif
#endif
#if defined(ANSICONSOLE)
#define HEADLINE "\x1B[1m"
#ifdef UNIX