summaryrefslogtreecommitdiffstats
path: root/src/bytearray.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytearray.c')
-rw-r--r--src/bytearray.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bytearray.c b/src/bytearray.c
index fff5089..7d0549b 100644
--- a/src/bytearray.c
+++ b/src/bytearray.c
@@ -23,10 +23,10 @@
23 23
24#define PAGE_SIZE 4096 24#define PAGE_SIZE 4096
25 25
26bytearray_t *byte_array_new() 26bytearray_t *byte_array_new(size_t initial)
27{ 27{
28 bytearray_t *a = (bytearray_t*)malloc(sizeof(bytearray_t)); 28 bytearray_t *a = (bytearray_t*)malloc(sizeof(bytearray_t));
29 a->capacity = PAGE_SIZE * 8; 29 a->capacity = (initial > PAGE_SIZE) ? (initial+(PAGE_SIZE-1)) & (~(PAGE_SIZE-1)) : PAGE_SIZE;
30 a->data = malloc(a->capacity); 30 a->data = malloc(a->capacity);
31 a->len = 0; 31 a->len = 0;
32 return a; 32 return a;