From da7bdf8ab7dc999009b6b83d3354066c18ec4f38 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Mon, 13 Jul 2026 11:48:52 +0100 Subject: xmalloc: avoid using reallocarray(3) to implement xreallocarray() See the added comment for reasoning. The reallocarray(3) function in libc could have been used conditionally, when available, but since it can be implemented simply and efficiently, the portable version may just as well be used in all cases. See also: * https://pubs.opengroup.org/onlinepubs/9799919799/functions/reallocarray.html#:~:text=adding-,reallocarray * https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md#:~:text=reallocarray * https://github.com/termux/termux-packages/tree/26826aec834182c/x11-packages/foot * https://github.com/termux/termux-packages/blob/26826aec834182c/x11-packages/foot/reallocarray.c#L6 * https://github.com/termux/termux-packages/blob/26826aec834182c/x11-packages/foot/xmalloc.c.patch#L7 * https://github.com/termux/termux-packages/pull/17818 * https://github.com/termux/termux-packages/issues/23833 (see expanded build log) --- debug.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'debug.h') diff --git a/debug.h b/debug.h index 92a0e091..29ff9606 100644 --- a/debug.h +++ b/debug.h @@ -2,7 +2,8 @@ #include "macros.h" -#define FATAL_ERROR(...) fatal_error(__FILE__, __LINE__, __VA_ARGS__) +#define FATAL_ERROR(msg, err) fatal_error(__FILE__, __LINE__, msg, err) +#define FATAL_ERROR_ON(cond, err) if (unlikely(cond)) FATAL_ERROR(__func__, err) #ifdef NDEBUG #define BUG(...) UNREACHABLE() -- cgit v1.3