summaryrefslogtreecommitdiff
path: root/src/piece-table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/piece-table.c')
-rw-r--r--src/piece-table.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/piece-table.c b/src/piece-table.c
index 497c71a..a8ddd1e 100644
--- a/src/piece-table.c
+++ b/src/piece-table.c
@@ -74,9 +74,15 @@ text_buffer_init (text_buffer *tb)
void
text_buffer_append (text_buffer *tb, char c)
{
- if (tb->size == tb->len)
+ size_t base_size = 1024;
+ if (tb->size == 0)
{
- tb->contents = realloc(tb->contents, sizeof(*tb->contents) * tb->len*2);
+ tb->contents = malloc (sizeof(*tb->contents) * base_size);
+ tb->size = base_size;
+ }
+ else if (tb->size == tb->len)
+ {
+ tb->contents = realloc (tb->contents, sizeof(*tb->contents) * tb->len*2);
}
tb->contents[tb->len++] = c;
}