diff --git a/lib/alloc/calloc.h b/lib/alloc/calloc.h index 5c093434..fb170e6f 100644 --- a/lib/alloc/calloc.h +++ b/lib/alloc/calloc.h @@ -11,7 +11,10 @@ #include -#define CALLOC(n, type) ((type *) calloc(n, sizeof(type))) +#define CALLOC(n, type) \ +( \ + (type *) calloc(n, sizeof(type)) \ +) #endif // include guard diff --git a/lib/alloc/malloc.h b/lib/alloc/malloc.h index 5badeebb..21478255 100644 --- a/lib/alloc/malloc.h +++ b/lib/alloc/malloc.h @@ -13,7 +13,10 @@ #include "attr.h" -#define MALLOC(n, type) ((type *) mallocarray(n, sizeof(type))) +#define MALLOC(n, type) \ +( \ + (type *) mallocarray(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/alloc/x/xcalloc.h b/lib/alloc/x/xcalloc.h index b78d104f..04cf1ad4 100644 --- a/lib/alloc/x/xcalloc.h +++ b/lib/alloc/x/xcalloc.h @@ -14,7 +14,10 @@ #include "attr.h" -#define XCALLOC(n, type) ((type *) xcalloc(n, sizeof(type))) +#define XCALLOC(n, type) \ +( \ + (type *) xcalloc(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/alloc/x/xmalloc.h b/lib/alloc/x/xmalloc.h index 967e18bc..02fde662 100644 --- a/lib/alloc/x/xmalloc.h +++ b/lib/alloc/x/xmalloc.h @@ -14,7 +14,10 @@ #include "attr.h" -#define XMALLOC(n, type) ((type *) xmallocarray(n, sizeof(type))) +#define XMALLOC(n, type) \ +( \ + (type *) xmallocarray(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/must_be.h b/lib/must_be.h index a7365cba..6ae6c799 100644 --- a/lib/must_be.h +++ b/lib/must_be.h @@ -90,10 +90,28 @@ */ -#define is_same_type(a, b) __builtin_types_compatible_p(a, b) -#define is_same_typeof(a, b) is_same_type(typeof(a), typeof(b)) -#define is_array(a) (!is_same_typeof((a), &(a)[0])) -#define must_be_array(a) must_be(is_array(a)) +#define is_same_type(a, b) \ +( \ + __builtin_types_compatible_p(a, b) \ +) + + +#define is_same_typeof(a, b) \ +( \ + is_same_type(typeof(a), typeof(b)) \ +) + + +#define is_array(a) \ +( \ + !is_same_typeof(a, &(a)[0]) \ +) + + +#define must_be_array(a) \ +( \ + must_be(is_array(a)) \ +) #endif // include guard