aboutsummaryrefslogtreecommitdiff
path: root/xmalloc.h
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2026-07-13 10:48:52 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-07-21 09:00:52 +0000
commitda7bdf8ab7dc999009b6b83d3354066c18ec4f38 (patch)
tree1b2a6f33a3b5547f4e8d3f51558d09298cf53bee /xmalloc.h
parentconfig: add ferra theme (diff)
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)
Diffstat (limited to 'xmalloc.h')
-rw-r--r--xmalloc.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/xmalloc.h b/xmalloc.h
index 03e6eb0d..33a17ca5 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -12,7 +12,7 @@
void *xmalloc(size_t size) XMALLOC;
void *xcalloc(size_t nmemb, size_t size) XMALLOC;
void *xrealloc(void *ptr, size_t size);
-void *xreallocarray(void *ptr, size_t n, size_t size);
+void *xreallocarray(void *ptr, size_t nmemb, size_t size);
char *xstrdup(const char *str) XSTRDUP;
char *xstrndup(const char *str, size_t n) XSTRDUP;
char *xasprintf(const char *format, ...) PRINTF(1) XMALLOC;