summaryrefslogtreecommitdiffstats
path: root/src/growbuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/growbuf.h')
-rw-r--r--src/growbuf.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/growbuf.h b/src/growbuf.h
index cd6a67b..2f8075b 100644
--- a/src/growbuf.h
+++ b/src/growbuf.h
@@ -13,6 +13,7 @@ class GrowBuf
GrowBuf() : m_str(0), m_pos(0), m_len(0) {}
GrowBuf(uint initialSize) : m_pos(0), m_len(initialSize) { m_str=(char*)malloc(m_len); }
~GrowBuf() { free(m_str); }
+ void reserve(uint size) { if (m_len<size) { m_len = size; m_str = (char*)realloc(m_str,m_len); } }
void clear() { m_pos=0; }
void addChar(char c) { if (m_pos>=m_len) { m_len+=GROW_AMOUNT; m_str = (char*)realloc(m_str,m_len); }
m_str[m_pos++]=c;