#include "mempool.h"#include <new>

Go to the source code of this file.
Defines | |
| #define | CXX_NEW(constructor, mempool) |
| #define | CXX_NEW_ARRAY(constructor, elements, mempool) |
| #define | CXX_NEW_VARIANT(constructor, pad, mempool) |
| #define | CXX_DELETE(pointer, mempool) |
| #define | CXX_DELETE_ARRAY(pointer, mempool) |
Variables | |
| MEM_POOL * | Delete_Mem_Pool |
| MEM_POOL * | _dummy_new_mempool |
| MEM_POOL * | _dummy_delete_mempool |
| size_t | _dummy_pad |
| #define CXX_DELETE | ( | pointer, | |||
| mempool | ) |
Value:
do { \ MEM_POOL* save_mpool = _dummy_delete_mempool; \ _dummy_delete_mempool = mempool; \ delete pointer; \ _dummy_delete_mempool = save_mpool; \ } while (0)
Definition at line 197 of file cxx_memory.h.
| #define CXX_DELETE_ARRAY | ( | pointer, | |||
| mempool | ) |
Value:
do { \ MEM_POOL* save_mpool = _dummy_delete_mempool; \ _dummy_delete_mempool = mempool; \ delete [] pointer; \ _dummy_delete_mempool = save_mpool; \ } while (0)
Definition at line 205 of file cxx_memory.h.
| #define CXX_NEW | ( | constructor, | |||
| mempool | ) |
Value:
(_dummy_new_mempool = mempool, \ new constructor)
Definition at line 184 of file cxx_memory.h.
| #define CXX_NEW_ARRAY | ( | constructor, | |||
| elements, | |||||
| mempool | ) |
Value:
(_dummy_new_mempool = mempool, \ new constructor [elements])
Definition at line 188 of file cxx_memory.h.
| #define CXX_NEW_VARIANT | ( | constructor, | |||
| pad, | |||||
| mempool | ) |
Value:
(_dummy_new_mempool = mempool, \ _dummy_pad = pad, new constructor)
Definition at line 192 of file cxx_memory.h.
Definition at line 45 of file cxx_memory.cxx.
Definition at line 44 of file cxx_memory.cxx.
Description:
C++ macro replacements for new and delete using memory pools. new and delete should never be used in the compiler; these should be used instead.
Exported preprocessor macro
CXX_USE_STANDARD_NEW_AND_DELETE
If this preprocessor macro is defined, then the macros below just ignore the memory pools and call the normal new and delete.
Exported functions:
CXX_NEW(constructor, MEM_POOL*)
Use CXX_NEW instead of new. E.g.
X* x = new X(3,4);
should be replaced by
X* x = CXX_NEW(X(3,4), malloc_pool);
(or whatever appropriate pool name).
CXX_NEW_ARRAY(constructor, elements, MEM_POOL*)
Use CXX_NEW_ARRAY instead of new []. E.g.
X* x = new X[a*b];
should be replaced by
X* x = CXX_NEW_ARRAY(X, a*b, malloc_pool);
(or whatever appropriate pool name).
CXX_NEW_VARIANT(constructor, pad, MEM_POOL*)
Like CXX_NEW allocates an instance of type "constructor"
but allocates "pad" amount of extra storage
Could be viewed as X* x = (X*) malloc (sizeof(X)+pad)
Followed by a call to the constructor for X.
There is no C++ equivalent. Therefore not available when using
standard new and delete.
CXX_DELETE(pointer, MEM_POOL*)
Use CXX_DELETE instead of delete. E.g.
delete p;
should be replaced by
(or whatever appropriate pool name).
CXX_DELETE_ARRAY(pointer, MEM_POOL*)
Use CXX_DELETE_ARRAY instead of delete[]. E.g.
delete[] p;
should be replaced by
CXX_DELETE_ARRAY(p, malloc_pool);
(or whatever appropriate pool name).
1.5.6