mirror of https://gitlab.com/rnger/amath
Fixed memory bug
This commit is contained in:
parent
b3753232f2
commit
be6681d3f0
|
@ -43,6 +43,29 @@
|
||||||
#define Debug(x,y,z,w)
|
#define Debug(x,y,z,w)
|
||||||
#endif
|
#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
|
||||||
{
|
{
|
||||||
struct MemoryBlock *next;
|
struct MemoryBlock *next;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#define AMATH_LIB_PLATFROM_H
|
#define AMATH_LIB_PLATFROM_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
#define EMPTYSTRING ""
|
#define EMPTYSTRING ""
|
||||||
#define SPACE " "
|
#define SPACE " "
|
||||||
|
@ -128,6 +129,23 @@ typedef u_int16_t uint16_t;
|
||||||
typedef u_int32_t uint32_t;
|
typedef u_int32_t uint32_t;
|
||||||
typedef u_int64_t uint64_t;
|
typedef u_int64_t uint64_t;
|
||||||
# define IPTR LONG*
|
# define IPTR LONG*
|
||||||
|
#ifdef __cplusplus
|
||||||
|
inline void* operator new (size_t size) {
|
||||||
|
return AllocMemSafe(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* operator new[] (size_t size) {
|
||||||
|
return AllocMemSafe(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void operator delete (void* ptr) {
|
||||||
|
FreeMemSafe(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void operator delete[] (void* ptr) {
|
||||||
|
FreeMemSafe(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ANSICONSOLE)
|
#if defined(ANSICONSOLE)
|
||||||
|
|
Loading…
Reference in New Issue