Remove mallocarray(...) and use reallocarray(NULL, ...)

After a short correspondence with Otto Moerbeek it turned out
mallocarray() is only in the OpenBSD-Kernel, because the kernel-
malloc doesn't have realloc.
Userspace applications should rather use reallocarray with an
explicit NULL-pointer.

Assuming reallocarray() will become available in c-stdlibs in the
next few years, we nip mallocarray() in the bud to allow an easy
transition to a system-provided version when the day comes.
This commit is contained in:
FRIGN
2015-03-11 10:50:18 +01:00
parent d6818a3c5f
commit 833c2aebb4
12 changed files with 15 additions and 68 deletions

2
cut.c
View File

@@ -56,7 +56,7 @@ parselist(char *str)
if (*s == ',')
n++;
}
r = emallocarray(n, sizeof(*r));
r = ereallocarray(NULL, n, sizeof(*r));
for (s = str; n; n--, s++) {
r->min = (*s == '-') ? 1 : strtoul(s, &s, 10);
r->max = (*s == '-') ? strtoul(s + 1, &s, 10) : r->min;