X-Git-Url: http://www.sigaev.ru/git/gitweb.cgi?a=blobdiff_plain;f=tmalloc.c;fp=tmalloc.c;h=8b16322463a6e7d30363fca2d5d8e7b2cef415fa;hb=defbac8338fc0b55c3e7b6eded770edc713122e2;hp=0d51e75cee71899effc04a1b92f5d8586399896e;hpb=d87148e06e0655d4a0b9eca3e46082d5b0b48210;p=tedtools.git diff --git a/tmalloc.c b/tmalloc.c index 0d51e75..8b16322 100644 --- a/tmalloc.c +++ b/tmalloc.c @@ -320,8 +320,11 @@ appendStringBuffer( StringBuffer *state, char *string, int stringlen) { return state; while ( state->len - ( state->ptr - state->buf ) < stringlen + 1 ) { + int diff = state->ptr - state->buf; + state->len *= 2; state->buf = (char*)mcrealloc( (void*)state->buf, state->len ); + state->ptr = state->buf + diff; } memcpy(state->ptr, string, stringlen);