These changes are necessary with glibc 2.17 and g++ 4.8.5
on CentOS 7.x. We don't have to worry about overflow with
realloc(3) here since WORKER_MAX is only USHRT_MAX and
sizeof(pid_t) is 4 bytes on every platform I've encountered.
#include <limits.h>
#include <search.h>
#include <signal.h>
+#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
warnx("workers cannot exceed %zu", (size_t)WORKER_MAX);
return;
}
- void *p = reallocarray(worker_pids, nworker + 1, sizeof(pid_t));
+ void *p = realloc(worker_pids, (nworker + 1) * sizeof(pid_t));
if (!p) {
- warn("reallocarray");
+ warn("realloc worker_pids");
} else {
worker_pids = (pid_t *)p;
worker_pids[nworker++] = 0;