diff options
Diffstat (limited to 'src/growbuf.h')
-rw-r--r-- | src/growbuf.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/growbuf.h b/src/growbuf.h index bc8e4b5..4c49dce 100644 --- a/src/growbuf.h +++ b/src/growbuf.h @@ -11,11 +11,21 @@ class GrowBuf { public: GrowBuf() : str(0), pos(0), len(0) {} + GrowBuf(int initialSize) : pos(0), len(initialSize) { str=(char*)malloc(len); } ~GrowBuf() { free(str); str=0; pos=0; len=0; } void clear() { pos=0; } void addChar(char c) { if (pos>=len) { len+=GROW_AMOUNT; str = (char*)realloc(str,len); } str[pos++]=c; } + void addStr(const QCString &s) { + if (!s.isEmpty()) + { + int l=s.length(); + if (pos+l>=len) { len+=l+GROW_AMOUNT; str = (char*)realloc(str,len); } + strcpy(&str[pos],s.data()); + pos+=l; + } + } void addStr(const char *s) { if (s) { |