--- parser3/src/include/pa_array.h 2025/05/28 00:58:02 1.104 +++ parser3/src/include/pa_array.h 2026/04/25 13:38:46 1.108 @@ -1,14 +1,14 @@ /** @file Parser: Array & Array_iterator classes decls. - Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_ARRAY_H #define PA_ARRAY_H -#define IDENT_PA_ARRAY_H "$Id: pa_array.h,v 1.104 2025/05/28 00:58:02 moko Exp $" +#define IDENT_PA_ARRAY_H "$Id: pa_array.h,v 1.108 2026/04/25 13:38:46 moko Exp $" // includes @@ -227,6 +227,11 @@ protected: void resize(size_t asize) { if(fallocated){ felements=(T *)pa_realloc(felements, asize*sizeof(T)); +#ifdef PA_DEBUG_DISABLE_GC + // non-gc realloc doesn't zero; manually zero expanded region + if(asize > fallocated) + memset((void *)(felements+fallocated), 0, (asize-fallocated) * sizeof(T)); +#endif fallocated=asize; } else { fallocated=asize; @@ -241,43 +246,6 @@ private: //disabled }; -/// Commonly used, templated to work with any integer type - -template char* pa_itoa(T n, T base=10){ - char buf[MAX_NUMBER + 1]; - char* pos=buf + MAX_NUMBER; - *pos='\0'; - - bool negative=n < 0; - if (n < 0){ - n=-n; - } - - do { - *(--pos)=(char)(n % base) + '0'; - n/=base; - } while (n > 0); - - if (negative) { - *(--pos) = '-'; - } - return pa_strdup(pos, buf + MAX_NUMBER - pos); -} - -template char* pa_uitoa(T n, T base=10){ - char buf[MAX_NUMBER + 1]; - char* pos=buf + MAX_NUMBER; - *pos='\0'; - - do { - *(--pos)=(char)(n % base) + '0'; - n/=base; - } while (n > 0); - - return pa_strdup(pos, buf + MAX_NUMBER - pos); -} - - /** Array iterator, usage: @code // Array a;