osprey/dipa/rta/open64/cxx_memory.h File Reference

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

Include dependency graph for cxx_memory.h:

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_POOLDelete_Mem_Pool
MEM_POOL_dummy_new_mempool
MEM_POOL_dummy_delete_mempool
size_t _dummy_pad


Define Documentation

#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.


Variable Documentation

Definition at line 45 of file cxx_memory.cxx.

Definition at line 44 of file cxx_memory.cxx.

Definition at line 46 of file cxx_memory.cxx.

Referenced by operator new().

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

CXX_DELETE(p, malloc_pool);

(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).

Revision
1.1
Date
2005/07/27 02:17:56
Author
kevinlo
Source
/depot/CVSROOT/javi/src/sw/cmplr/common/util/cxx_memory.h,v


Generated on Wed Apr 8 14:42:51 2009 for Open64 by  doxygen 1.5.6