summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bufstr.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bufstr.h b/src/bufstr.h
index 427b012..cfb89c4 100644
--- a/src/bufstr.h
+++ b/src/bufstr.h
@@ -33,7 +33,7 @@ class BufStr
BufStr(int size)
: m_size(size), m_writeOffset(0), m_spareRoom(10240), m_buf(0)
{
- m_buf = (char *)malloc(size);
+ m_buf = (char *)calloc(size,1);
}
~BufStr()
{
@@ -62,12 +62,17 @@ class BufStr
}
void resize( uint newlen )
{
+ uint oldsize = m_size;
m_size=newlen;
if (m_writeOffset>=m_size) // offset out of range -> enlarge
{
m_size=m_writeOffset+m_spareRoom;
}
m_buf = (char *)realloc(m_buf,m_size);
+ if (m_size>oldsize)
+ {
+ memset(m_buf+oldsize,0,m_size-oldsize);
+ }
}
int size() const
{