Itasca C++ Interface
Loading...
Searching...
No Matches
basememory.h
Go to the documentation of this file.
1#include <stdlib.h>
2
3#pragma once
14#include "basedef.h"
15#include <new>
16
17#ifdef _DEBUG
18 #define ITASCA_MEMORY_CHECKING
19#else
20 //#define ITASCA_MEMORY_CHECKING
21#endif
22
23namespace itasca {
24 namespace memory {
25 using MemoryCleanupFunction = void(*)();
26
27 void initialize();
28 void shutdown();
29 BASE_EXPORT void * imalloc(size_t s);
30 BASE_EXPORT void * imalloc(size_t s,const char *file,uint32 line);
31 BASE_EXPORT void ifree(void *v);
32 BASE_EXPORT bool heapCheck(void *memptr = nullptr);
33 BASE_EXPORT uint64 getMemory();
34 BASE_EXPORT void addCleanupFunction(MemoryCleanupFunction func);
35 } // namespace memory
36} // namespace itasca
37
38#ifdef ITASCA_MEMORY_CHECKING
42 inline void* operator new(size_t s, const char* file, unsigned line) {
43 return itasca::memory::imalloc(s, file, line);
44 }
45 inline void* operator new[](size_t s, const char* file, unsigned line) {
46 return itasca::memory::imalloc(s, file, line);
47 }
48 void *operator new(size_t s);
49 #define NEW new(__FILE__,__LINE__)
50 #define NEWN(x) new(x,__LINE__)
51#else
52 #define NEW new
53 #define NEWN(x) new
54#endif // _WIN32
55
56
57
59// EoF
Base type definitions for the engine.
#define BASE_EXPORT
Definition basedef.h:24
namespace Itasca
Definition basememory.cpp:14