7 /** Class representing a string buffer optimised for growing. */
11 GrowBuf() : str(0), pos(0), len(0) {}
12 ~GrowBuf() { free(str); str=0; pos=0; len=0; }
13 void clear() { pos=0; }
14 void addChar(char c) { if (pos>=len) { len+=1024; str = (char*)realloc(str,len); }
17 void addStr(const char *s) {
19 if (pos+l>=len) { len+=l+1024; str = (char*)realloc(str,len); }
23 void addStr(const char *s,int n) {
26 if (pos+l>=len) { len+=l+1024; str = (char*)realloc(str,len); }
27 strncpy(&str[pos],s,n);
30 const char *get() { return str; }
31 int getPos() const { return pos; }
32 char at(int i) const { return str[i]; }