summaryrefslogtreecommitdiff
path: root/vec.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-10-24 03:13:14 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-10-24 03:13:14 +0100
commit3a8f0c8d00bd7c87404763e7c1f9c9e484810869 (patch)
tree03d5d391782a9cc14576ebd5fb17fb625f1321ae /vec.h
parent14dea7c48c1f087167f7cbd6c8ebc4bb9aec2a14 (diff)
downloadprick-3a8f0c8d00bd7c87404763e7c1f9c9e484810869.tar.gz
prick-3a8f0c8d00bd7c87404763e7c1f9c9e484810869.tar.bz2
prick-3a8f0c8d00bd7c87404763e7c1f9c9e484810869.zip
Use VEC_MULT in vec_ensure_remaining
Diffstat (limited to 'vec.h')
-rw-r--r--vec.h5
1 files 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