From ff1af0e4cbb7cdd26cf3941f487f7f519646acab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Londeix?= Date: Sat, 5 Dec 2015 13:13:09 +0000 Subject: [PATCH] ALLOCATE_* family macros cast to the destination type They were previously evaluated as an expression of `void *` type. This allows a C++ compiler to assign it a variable of the destination type. --- src/util.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util.h b/src/util.h index 5d45f4e..63babe9 100644 --- a/src/util.h +++ b/src/util.h @@ -13,11 +13,11 @@ #include #include -#define ALLOCATE_NONZERO(Type, count) malloc((count) * sizeof(Type)) +#define ALLOCATE_NONZERO(Type, count) ((Type*)malloc((count) * sizeof(Type))) -#define ALLOCATE(Type, count) calloc(count, sizeof(Type)) +#define ALLOCATE(Type, count) ((Type*)calloc(count, sizeof(Type))) -#define REALLOCATE_NONZERO(Type, old, new_count) realloc(old, (new_count) * sizeof(Type)) +#define REALLOCATE_NONZERO(Type, old, new_count) ((Type*)realloc(old, (new_count) * sizeof(Type))) #define ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0]))