includes: add xalloc.h to unify memory allocations

The xalloc.h provides necessary error checking.

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola
2011-10-09 21:29:26 +02:00
parent 4bd36d1483
commit 1ef14f4bf9
7 changed files with 94 additions and 48 deletions

6
pmap.c
View File

@ -26,6 +26,7 @@
#include "c.h"
#include "nls.h"
#include "proc/escape.h"
#include "xalloc.h"
#include "proc/readproc.h"
#include "proc/version.h"
@ -449,10 +450,7 @@ int main(int argc, char **argv)
if (d_option && x_option)
errx(EXIT_FAILURE, _("options -d and -x cannot coexist"));
pidlist = malloc(sizeof(unsigned) * argc);
if (pidlist == NULL)
err(EXIT_FAILURE, _("cannot allocate %zu bytes"),
sizeof(unsigned) * argc);
pidlist = xmalloc(sizeof(unsigned) * argc);
while (*argv) {
char *walk = *argv++;