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.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/piece-table.c b/src/piece-table.c
index 53a9088..21dbb1b 100644
--- a/src/piece-table.c
+++ b/src/piece-table.c
@@ -72,6 +72,13 @@ text_buffer_init (text_buffer *tb)
}
void
+text_buffer_resize (text_buffer *tb, size_t size)
+{
+ tb->size = size;
+ tb->contents = realloc (tb->contents, sizeof (*tb->contents) * size);
+}
+
+void
text_buffer_append (text_buffer *tb, char c)
{
size_t base_size = 1024;
@@ -81,10 +88,7 @@ text_buffer_append (text_buffer *tb, char c)
tb->size = base_size;
}
else if (tb->size == tb->used)
- {
- tb->contents = realloc (tb->contents,
- sizeof (*tb->contents) * tb->used*2);
- }
+ text_buffer_resize (tb, tb->size * 2);
tb->contents[tb->used++] = c;
}