diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/buffer.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/util/buffer.c b/util/buffer.c index cedd055..7ddd693 100644 --- a/util/buffer.c +++ b/util/buffer.c @@ -20,10 +20,13 @@ #include "qemu/buffer.h" +#define BUFFER_MIN_INIT_SIZE 4096 + void buffer_reserve(Buffer *buffer, size_t len) { if ((buffer->capacity - buffer->offset) < len) { - buffer->capacity += (len + 1024); + buffer->capacity = pow2ceil(buffer->offset + len); + buffer->capacity = MAX(buffer->capacity, BUFFER_MIN_INIT_SIZE); buffer->buffer = g_realloc(buffer->buffer, buffer->capacity); } } |