11 #define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
14 #ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
22 template <
class T> T*
xNew(
unsigned int size,
const char*
const contig = &
DEFCONTIG){
24 template <
class T> T*
xNew(
unsigned int size){
26 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
31 T* aT_p=(T*)malloc(size*
sizeof(T));
36 template <
class T> T**
xNew(
unsigned int dim1,
unsigned int dim2) {
37 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
38 T* buf=xNew<T>(dim1*dim2);
39 T** aT_pp =
new T*[dim1];
41 for (
unsigned int i=0;i<dim1;++i) {
47 T* buf=(T*)malloc(dim1*dim2*
sizeof(T));
49 T** aT_pp =(T**)malloc(dim1*
sizeof(T*));
51 for (
unsigned int i=0;i<dim1;++i) {
64 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
66 T* aT_p=xNew<T>(size,contig);
68 T* aT_p=xNew<T>(size);
70 for (
unsigned int i=0; i<size;++i)
74 T* aT_p=(T*)calloc(size,
sizeof(T));
79 template <
class T> T**
xNewZeroInit(
unsigned int dim1,
unsigned int dim2) {
80 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
81 T** aT_pp=xNew<T>(dim1,dim2);
82 for (
unsigned int i=0; i<dim1*dim2;++i)
86 T* buf=(T*)calloc(dim1*dim2*
sizeof(T));
88 T** aT_pp =(T**)malloc(dim1*
sizeof(T*));
90 for (
unsigned int i=0;i<dim1;++i) {
97 template <
class T>
void xDelete(T**& aT_pp) {
99 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
111 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
118 template <
class T> T*
xReNew(T* old,
unsigned int old_size,
unsigned int size) {
119 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
135 unsigned int iMax=(old_size<size)?old_size:size;
136 for (
unsigned int i=0; i<iMax;++i) {
146 aT_p=(T*)realloc((
void*)old,size*
sizeof(T));
152 template <
class T> T*
xMemCpy(T* dest,
const T* src,
unsigned int size) {
153 assert(dest); assert(src);
154 for (
int i=0; i<size;++i)
160 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)
161 #include "../Numerics/types.h"
162 template <> adouble*
xNew(
unsigned int size,
const char*
const contig);