19 #ifndef RESERVEARRAY_H
20 #define RESERVEARRAY_H
22 #define RESERVEARRAY(TYPE,NAME,RSIZE,SIZE) \
24 ReserveArray<TYPE,RSIZE> NAME ## _reserve(SIZE,&NAME);
26 template <
class Elem,
int reservedSize>
class ReserveArray {
28 Elem *allocatedStorage;
29 Elem reservedStorage[reservedSize];
33 ReserveArray(
int size, Elem **userStorage) {
34 if ( size > reservedSize ) {
35 *userStorage = allocatedStorage =
new Elem[size];
36 }
else if ( size > 0 ) {
38 *userStorage = reservedStorage;
46 delete [] allocatedStorage;