--- parser3/src/include/pa_array.h 2003/02/04 09:44:27 1.57.2.19 +++ parser3/src/include/pa_array.h 2003/02/17 12:13:43 1.57.2.24 @@ -8,7 +8,7 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char* IDENT_ARRAY_Y="$Date: 2003/02/04 09:44:27 $"; +static const char* IDENT_ARRAY_Y="$Date: 2003/02/17 12:13:43 $"; #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 @@ -89,16 +89,22 @@ public: limit=m; } - int needed=limit-(fallocated-fused); - if(needed>0) - expand(needed); - - memcpy(&felements[fused+=limit], &src.felements[offset], limit*sizeof(T)); + int delta=limit-(fallocated-fused); + if(delta>0) + expand(delta); + + T* from=&src.felements[offset]; + T* to=&felements[fused]; + T* from_end=from+limit; + while(from=0 && index 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) { @@ -173,6 +184,8 @@ public: memcpy(result, buf, size); return result; } + + char *format_integer(int value); }; inline void *operator new[] (size_t size, Pool& pool) {