From ad4999488eadac3a10de99caf50b732af8b771b9 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 22 Aug 2014 17:47:51 +0200 Subject: Remove VECTOR_ALLOC It is done automatically now if the VECTOR is zeroed before. --- src/vector.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/vector.c') diff --git a/src/vector.c b/src/vector.c index 04dd934..054470e 100644 --- a/src/vector.c +++ b/src/vector.c @@ -40,22 +40,6 @@ #define MIN_VECTOR_ALLOC 4 -/** - Allocates a new vector - - Internal function, use VECTOR_ALLOC() instead. -*/ -void _fastd_vector_alloc(fastd_vector_desc_t *desc, void **data, size_t n, size_t elemsize) { - desc->allocated = MIN_VECTOR_ALLOC; - - while (desc->allocated < n*3/2) - desc->allocated <<= 1; - - desc->length = n; - - *data = fastd_alloc(desc->allocated * elemsize); -} - /** Resizes a vector @@ -68,6 +52,11 @@ void _fastd_vector_resize(fastd_vector_desc_t *desc, void **data, size_t n, size size_t alloc = desc->allocated; + if (!alloc) { + alloc = MIN_VECTOR_ALLOC; + n = n*3/2; + } + while (alloc < n) alloc <<= 1; while (alloc > n*3 && alloc > MIN_VECTOR_ALLOC) -- cgit v1.2.3