--- parser3/src/include/pa_array.h 2003/02/17 07:18:58 1.57.2.21 +++ parser3/src/include/pa_array.h 2003/02/17 09:56:15 1.57.2.22 @@ -8,7 +8,7 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char* IDENT_ARRAY_Y="$Date: 2003/02/17 07:18:58 $"; +static const char* IDENT_ARRAY_Y="$Date: 2003/02/17 09:56:15 $"; #include "pa_pool.h" #include "pa_exception.h" @@ -50,14 +50,14 @@ public: Exception::undefined_source, "Array::Array(%d, %d) too small", initial, delta); - felements=new T[fallocated]; + felements=static_cast(calloc(fallocated*sizeof(T))); } override ~Array() { T *last=felements+fused; for(T *current=felements; current~T(); // manually invoking destructors - delete felements; + free(felements); } /// how many items are in Array @@ -146,8 +146,9 @@ protected: return fused == fallocated; } void expand(int delta) { + felements = (T *)realloc(felements, (fallocated+delta)*sizeof(T)); + memset(&felements[fallocated], 0, delta*sizeof(T)); fallocated+=delta; - felements = (T *)realloc(felements, fallocated*sizeof(T)); } private: //disabled @@ -157,6 +158,10 @@ private: //disabled typedef smart_ptr CharPtr; +/** + Pool mechanizm allows users not to free up allocated memory, + leaving that problem to 'pools'. +*/ class Pool: public Array { public: char *malloc(size_t size) {