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
printf.c
4
printf.c
@@ -111,7 +111,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'c':
|
||||
unescape(arg);
|
||||
rarg = emallocarray(utflen(arg) + 1, sizeof(*rarg));
|
||||
rarg = ereallocarray(NULL, utflen(arg) + 1, sizeof(*rarg));
|
||||
utftorunestr(arg, rarg);
|
||||
efputrune(rarg, stdout, "<stdout>");
|
||||
free(rarg);
|
||||
@@ -125,7 +125,7 @@ main(int argc, char *argv[])
|
||||
if (arg[j] == '\'' || arg[j] == '\"') {
|
||||
arg += j + 1;
|
||||
unescape(arg);
|
||||
rarg = emallocarray(utflen(arg) + 1, sizeof(*rarg));
|
||||
rarg = ereallocarray(NULL, utflen(arg) + 1, sizeof(*rarg));
|
||||
utftorunestr(arg, rarg);
|
||||
num = rarg[0];
|
||||
} else
|
||||
|
Reference in New Issue
Block a user