From 3a8f0c8d00bd7c87404763e7c1f9c9e484810869 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 24 Oct 2024 03:13:14 +0100 Subject: Use VEC_MULT in vec_ensure_remaining --- vec.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vec.h b/vec.h index d45f91c..1afee76 100644 --- a/vec.h +++ b/vec.h @@ -71,7 +71,7 @@ void vec_ensure_remaining(void **ptr, uint32_t space) if (vec->capacity - vec->size < space) { void *new_vec = NULL; - vec_make(&new_vec, MAX(vec->capacity * 2, vec->size + space)); + vec_make(&new_vec, MAX(vec->capacity * VEC_MULT, vec->size + space)); VEC_SIZE(new_vec) = vec->size; memcpy(new_vec, *ptr, vec->size); vec_free(ptr); @@ -90,7 +90,7 @@ void vec_append(void **ptr, void *data, uint32_t size) { vec_ensure_remaining(ptr, size); vec_t *vec = VEC_GET(*ptr); - memcpy(vec->bytes + vec->size, data, size); + memcpy(*ptr + vec->size, data, size); vec->size += size; } @@ -102,6 +102,7 @@ void vec_clone(void **dest, void **src) memcpy(*dest, *src, VEC_SIZE(*src)); VEC_SIZE(*dest) = VEC_SIZE(*src); } + #endif #endif -- cgit v1.2.3-13-gbd6f