diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2013-11-22 13:24:52 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-01-08 14:59:38 +0100 |
commit | 9973ef0207d21535a05610ca50d9f45c7c56c758 (patch) | |
tree | b6049b899f23d7447ee39077f80e2dd2f86d3d2b /vector.c | |
parent | e21da6c2a6ffcd8b4a2b2b06cf7486f36f291a5b (diff) |
Use argv_array in place of vector
Instead of using our own vector implementation, use argv_array from Git
which has been specifically designed for dynamic size argv arrays.
Drop vector.h and vector.c which are no longer needed.
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'vector.c')
-rw-r--r-- | vector.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/vector.c b/vector.c deleted file mode 100644 index 0863908..0000000 --- a/vector.c +++ /dev/null @@ -1,38 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include "vector.h" - -static int grow(struct vector *vec, int gently) -{ - size_t new_alloc; - void *new_data; - - new_alloc = vec->alloc * 3 / 2; - if (!new_alloc) - new_alloc = 8; - new_data = realloc(vec->data, new_alloc * vec->size); - if (!new_data) { - if (gently) - return ENOMEM; - perror("vector.c:grow()"); - exit(1); - } - vec->data = new_data; - vec->alloc = new_alloc; - return 0; -} - -int vector_push(struct vector *vec, const void *data, int gently) -{ - int rc; - - if (vec->count == vec->alloc && (rc = grow(vec, gently))) - return rc; - if (data) - memmove(vec->data + vec->count * vec->size, data, vec->size); - else - memset(vec->data + vec->count * vec->size, 0, vec->size); - vec->count++; - return 0; -} |