--- parser3/src/include/pa_array.h 2003/02/21 10:55:43 1.57.2.25 +++ parser3/src/include/pa_array.h 2003/03/08 12:22:06 1.57.2.27 @@ -8,7 +8,7 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char* IDENT_ARRAY_H="$Date: 2003/02/21 10:55:43 $"; +static const char* IDENT_ARRAY_H="$Date: 2003/03/08 12:22:06 $"; // includes @@ -42,18 +42,21 @@ public: typedef T element_type; Array(int initial=3, int delta=1): - fallocated(initial?initial:3), + fallocated(initial>3?initial:3), fdelta(delta), fused(0) { - if(fallocated<=0 || fdelta<1) + if(fdelta<1) throw Exception(0, Exception::undefined_source, - "Array::Array(%d, %d) too small", initial, delta); + "Array::Array(delta=%d) too small", delta); + // we can't use new(0) here[like we did in Hash] because we need to use realloc + // on MSVC new returns NOT pointer learned from pa_malloc, so we can't do new+realloc felements=static_cast(calloc(fallocated*sizeof(T))); } override ~Array() { + // see comment in ctor T *last=felements+fused; for(T *current=felements; current~T(); // manually invoking destructors