--- parser3/src/include/pa_array.h 2009/04/17 09:55:21 1.71 +++ parser3/src/include/pa_array.h 2009/04/30 04:39:06 1.77 @@ -8,7 +8,7 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char * const IDENT_ARRAY_Y="$Date: 2009/04/17 09:55:21 $"; +static const char * const IDENT_ARRAY_Y="$Date: 2009/04/30 04:39:06 $"; // includes @@ -80,9 +80,16 @@ public: fallocated(initial), fused(0) { - felements=fallocated?static_cast(malloc(fallocated*sizeof(T))):0; + felements=fallocated?(T *)pa_malloc(fallocated*sizeof(T)):0; } +#ifdef USE_DESTRUCTORS + inline ~Array(){ + if(felements) + pa_free(felements); + } +#endif + /// how many items are in Array inline size_t count() const { return fused; } /// append to array @@ -188,6 +195,10 @@ public: return T(0); } + inline T* ptr(size_t index){ + return felements + index; + } + protected: bool is_full() { @@ -196,12 +207,12 @@ protected: void expand(size_t delta) { if(fallocated){ size_t new_allocated=fallocated+delta; - felements = (T *)realloc(felements, new_allocated*sizeof(T)); + felements=(T *)pa_realloc(felements, new_allocated*sizeof(T)); memset(&felements[fallocated], 0, delta*sizeof(T)); fallocated=new_allocated; } else { fallocated=delta; - felements=static_cast(malloc(fallocated*sizeof(T))); + felements=(T *)pa_malloc(fallocated*sizeof(T)); } }