--- parser3/src/include/pa_array.h 2025/05/27 15:10:24 1.103 +++ parser3/src/include/pa_array.h 2026/01/06 13:07:58 1.106 @@ -8,12 +8,13 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -#define IDENT_PA_ARRAY_H "$Id: pa_array.h,v 1.103 2025/05/27 15:10:24 moko Exp $" +#define IDENT_PA_ARRAY_H "$Id: pa_array.h,v 1.106 2026/01/06 13:07:58 moko Exp $" // includes #include "pa_memory.h" #include "pa_types.h" +#include "pa_int.h" #include "pa_exception.h" // forwards @@ -227,6 +228,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 +247,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; @@ -318,11 +287,6 @@ public: inline size_t index() { return fcurrent - farray.felements; } - - // returns the current index string value of the iterator - inline char *key() { - return pa_uitoa(index()); - } }; // Slower array iterator for arrays that can be modified during iteration