#define REALLOC(p, n, T) REALLOC_(p, n, typeas(T))
#define REALLOC_(p, n, T) \
( \
- _Generic(p, T *: (T *) reallocarray(p, (n) ?: 1, sizeof(T))) \
+ _Generic(p, T *: (T *) reallocarray_(p, n, sizeof(T))) \
)
+#define reallocarray_(p, n, size) reallocarray(p, (n) ?: 1, (size) ?: 1)
+
#define XREALLOC(p, n, T) exit_if_null(REALLOC(p, n, T))
#define REALLOCF(p, n, T) REALLOCF_(p, n, typeas(T))
#define REALLOCF_(p, n, T) \
( \
- _Generic(p, T *: (T *) reallocarrayf(p, (n) ?: 1, sizeof(T))) \
+ _Generic(p, T *: (T *) reallocarrayf_(p, n, sizeof(T))) \
)
+#define reallocarrayf_(p, n, size) reallocarrayf(p, (n) ?: 1, (size) ?: 1)
+
ATTR_ALLOC_SIZE(2, 3)
ATTR_MALLOC(free)