diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/string.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/util/string.h b/src/util/string.h index 2268a36..6d44b53 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -54,15 +54,15 @@ struct ARRSTR { template <typename CT> struct __str : public LIST<CT> { __str() : LIST<CT>() {} - __str( U32 count, const CT* str ) : LIST<CT>() { + __str( U32 count, const CT* str ) { this->data = 0; - this->capacity = 0; + this->capacity = this->size = 0; this->reserve( count * 2 ); memcpy( this->data, str, count ); this->size = count; this->data[this->size] = 0; } - __str( const CT* fmt, ... ) : LIST<CT>() { + __str( const CT* fmt, ... ) { va_list args; va_start( args, fmt ); va_list args2; @@ -70,7 +70,7 @@ struct __str : public LIST<CT> { U32 c = vsnprintf( 0, 0, fmt, args ); va_end( args ); this->data = 0; - this->capacity = 0; + this->capacity = this->size = 0; this->reserve( c * 2 ); vsnprintf( this->data, c + 1, fmt, args2 ); this->data[c] = 0; @@ -165,7 +165,7 @@ struct __str : public LIST<CT> { __str<CT>& append( const CT* str ) { U32 len; for( len = 0; !!str[len]; ++len ); - if( this->size + len > this->capacity ) + if( this->size + len + 1 > this->capacity ) this->reserve( this->size + len + 1 ); memcpy( this->data + this->size, str, len * sizeof(CT) ); |
