From 3e0134782b942c1334e2cbb08ef4fce76e90301c Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Sat, 13 Jun 2009 22:26:23 +0300 Subject: [PATCH] strbuffer: Allocate enough space for value initially --- src/strbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strbuffer.c b/src/strbuffer.c index ea74b6d..2445a75 100644 --- a/src/strbuffer.c +++ b/src/strbuffer.c @@ -42,7 +42,7 @@ int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, int size) if(strbuff->length + size > strbuff->size) { if(strbuff->length == 0) - strbuff->size = STRBUFFER_MIN_SIZE; + strbuff->size = max(size + 1, STRBUFFER_MIN_SIZE); else strbuff->size = max(strbuff->size * STRBUFFER_FACTOR, strbuff->length + size + 1);