diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-02 00:53:47 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-02 00:53:47 +0200 |
commit | 546ac7936340312cf272969ff83317ae4d50d2b4 (patch) | |
tree | 7ecadca11430c8624d9f80aae7c348fa4d65b969 /src/vector.c | |
parent | b22364f4af3564f0dd9a5f4e150bb09747bd5c4e (diff) | |
download | fastd-546ac7936340312cf272969ff83317ae4d50d2b4.tar fastd-546ac7936340312cf272969ff83317ae4d50d2b4.zip |
Introduce and use alloc helpers
These new helpers will terminate fastd on allocation failures and add some
additional convenience (allow strdup with NULL; typesafe new(type) macros).
Diffstat (limited to 'src/vector.c')
-rw-r--r-- | src/vector.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vector.c b/src/vector.c index 6e8c18d..04dd934 100644 --- a/src/vector.c +++ b/src/vector.c @@ -31,6 +31,7 @@ #include "vector.h" +#include "alloc.h" #include <string.h> @@ -52,7 +53,7 @@ void _fastd_vector_alloc(fastd_vector_desc_t *desc, void **data, size_t n, size_ desc->length = n; - *data = malloc(desc->allocated * elemsize); + *data = fastd_alloc(desc->allocated * elemsize); } /** @@ -74,7 +75,7 @@ void _fastd_vector_resize(fastd_vector_desc_t *desc, void **data, size_t n, size if (alloc != desc->allocated) { desc->allocated = alloc; - *data = realloc(*data, alloc * elemsize); + *data = fastd_realloc(*data, alloc * elemsize); } } |