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:
4
tr.c
4
tr.c
@@ -78,9 +78,9 @@ makeset(char *str, struct range **set, int (**check)(Rune))
|
||||
|
||||
/* rstr defines at most len ranges */
|
||||
unescape(str);
|
||||
rstr = emallocarray(utflen(str) + 1, sizeof(*rstr));
|
||||
rstr = ereallocarray(NULL, utflen(str) + 1, sizeof(*rstr));
|
||||
len = utftorunestr(str, rstr);
|
||||
*set = emallocarray(len, sizeof(**set));
|
||||
*set = ereallocarray(NULL, len, sizeof(**set));
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (rstr[i] == '[') {
|
||||
|
Reference in New Issue
Block a user