diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-22 17:47:51 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-22 17:47:51 +0200 |
commit | ad4999488eadac3a10de99caf50b732af8b771b9 (patch) | |
tree | d3ffbbc2830b4bf2b520ae6b734d1c188d465be9 /src/vector.c | |
parent | 35a18b1dea21f006b38694dcf5c99f817411ad4d (diff) | |
download | fastd-ad4999488eadac3a10de99caf50b732af8b771b9.tar fastd-ad4999488eadac3a10de99caf50b732af8b771b9.zip |
Remove VECTOR_ALLOC
It is done automatically now if the VECTOR is zeroed before.
Diffstat (limited to 'src/vector.c')
-rw-r--r-- | src/vector.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/vector.c b/src/vector.c index 04dd934..054470e 100644 --- a/src/vector.c +++ b/src/vector.c @@ -41,22 +41,6 @@ /** - 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 Vector allocations are always powers of 2. @@ -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) |