--- parser3/src/include/pa_array.h 2009/04/17 13:13:09 1.72 +++ parser3/src/include/pa_array.h 2012/03/16 09:24:08 1.81 @@ -1,14 +1,14 @@ /** @file Parser: Array & Array_iterator classes decls. - Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char * const IDENT_ARRAY_Y="$Date: 2009/04/17 13:13:09 $"; +#define IDENT_PA_ARRAY_H "$Id: pa_array.h,v 1.81 2012/03/16 09:24:08 moko Exp $" // includes @@ -80,19 +80,22 @@ public: fallocated(initial), fused(0) { - felements=fallocated?static_cast(malloc(fallocated*sizeof(T))):0; + felements=fallocated?(T *)pa_malloc(fallocated*sizeof(T)):0; } - ~Array(){ - free(felements); +#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 inline Array& operator+=(T src) { if(is_full()) - expand(fallocated>0?2:3); // 3 is PAF default, confirmed by tests + expand(fallocated>0? 2+fallocated/32 : 3); // 3 is PAF default, confirmed by tests felements[fused++]=src; @@ -158,6 +161,13 @@ public: felements[index]=element; } + /// remove index-element + inline void remove(size_t index) { + assert(index(malloc(fallocated*sizeof(T))); + felements=(T *)pa_malloc(fallocated*sizeof(T)); } }