From 1398df1260ed9d6a76c2c097e8d41223e58a2f5e Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 13 Jan 2017 17:49:31 -0500 Subject: [PATCH] [fix] accept 0 for array_new_size --- src/vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector.h b/src/vector.h index 25b7896d..8a626ea6 100644 --- a/src/vector.h +++ b/src/vector.h @@ -34,7 +34,7 @@ static inline void _aligned_free(void *p) name *array = malloc(sizeof(name)); \ if (array == NULL) return NULL; \ array->n = array->m = 0; \ - array->a = malloc(size * sizeof(type)); \ + array->a = malloc((size > 0 ? size : 1) * sizeof(type)); \ if (array->a == NULL) return NULL; \ array->m = size; \ return array; \