summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-25 02:28:32 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-25 02:28:32 +0200
commit1723e18b1d92c3fe6d60ea8cef514901cac8e5ba (patch)
tree56f42ec8d555db6e854617a766af095c3abd5c56 /src
parent7fbaedb117ecbda4c7eba07818637f780daf5428 (diff)
downloadfastd-1723e18b1d92c3fe6d60ea8cef514901cac8e5ba.tar
fastd-1723e18b1d92c3fe6d60ea8cef514901cac8e5ba.zip
Reduce minimum vector allocation
Diffstat (limited to 'src')
-rw-r--r--src/vector.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/vector.c b/src/vector.c
index 153327e..bda1fe1 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -29,8 +29,11 @@
#include <string.h>
+#define MIN_VECTOR_ALLOC 4
+
+
void _fastd_vector_alloc(fastd_vector_desc_t *desc, void **data, size_t n, size_t elemsize) {
- desc->allocated = 16;
+ desc->allocated = MIN_VECTOR_ALLOC;
while (desc->allocated < n*3/2)
desc->allocated <<= 1;
@@ -47,7 +50,7 @@ void _fastd_vector_resize(fastd_vector_desc_t *desc, void **data, size_t n, size
while (alloc < n)
alloc <<= 1;
- while (alloc > n*3 && alloc > 16)
+ while (alloc > n*3 && alloc > MIN_VECTOR_ALLOC)
alloc >>= 1;
if (alloc != desc->allocated) {