22 #ifndef __RAK_MEMORY_H
23 #define __RAK_MEMORY_H
52 extern RAK_DLL_EXPORT void * (*rakMalloc_Ex) (
size_t size,
const char *file,
unsigned int line);
53 extern RAK_DLL_EXPORT void * (*rakRealloc_Ex) (
void *p,
size_t size,
const char *file,
unsigned int line);
89 #if _USE_RAK_MEMORY_OVERRIDE==1
90 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(Type), file, line);
91 Type *t =
new (buffer) Type;
100 template <
class Type,
class P1>
103 #if _USE_RAK_MEMORY_OVERRIDE==1
104 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(Type), file, line);
105 Type *t =
new (buffer) Type(p1);
114 template <
class Type,
class P1,
class P2>
117 #if _USE_RAK_MEMORY_OVERRIDE==1
118 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(Type), file, line);
119 Type *t =
new (buffer) Type(p1, p2);
124 return new Type(p1, p2);
128 template <
class Type,
class P1,
class P2,
class P3>
131 #if _USE_RAK_MEMORY_OVERRIDE==1
132 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(Type), file, line);
133 Type *t =
new (buffer) Type(p1, p2, p3);
138 return new Type(p1, p2, p3);
142 template <
class Type,
class P1,
class P2,
class P3,
class P4>
143 RAK_DLL_EXPORT Type*
OP_NEW_4(
const char *file,
unsigned int line,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4)
145 #if _USE_RAK_MEMORY_OVERRIDE==1
146 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(Type), file, line);
147 Type *t =
new (buffer) Type(p1, p2, p3, p4);
152 return new Type(p1, p2, p3, p4);
157 template <
class Type>
163 #if _USE_RAK_MEMORY_OVERRIDE==1
165 char *buffer = (
char *) (
GetMalloc_Ex())(
sizeof(
int)+
sizeof(Type)*count, file, line);
166 ((
int*)buffer)[0]=count;
167 for (
int i=0; i<count; i++)
170 new(buffer+
sizeof(int)+i*
sizeof(Type)) Type;
172 return (Type *) (buffer+
sizeof(int));
176 return new Type[count];
181 template <
class Type>
184 #if _USE_RAK_MEMORY_OVERRIDE==1
196 template <
class Type>
199 #if _USE_RAK_MEMORY_OVERRIDE==1
203 int count = ((
int*)((
char*)buff-
sizeof(int)))[0];
205 for (
int i=0; i<count; i++)
210 (
GetFree_Ex())((
char*)buff-
sizeof(int), file, line );