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

View File

@ -17,6 +17,7 @@
#include "config.h"
#include "nls.h"
#include "proc/procps.h"
#include "xalloc.h"
#include <ctype.h>
#include <errno.h>
#include <errno.h>
@ -366,13 +367,13 @@ int main(int argc, char *argv[])
/* save for later */
command_argv = &(argv[optind]);
command = strdup(argv[optind++]);
command = xstrdup(argv[optind++]);
command_length = strlen(command);
for (; optind < argc; optind++) {
char *endp;
int s = strlen(argv[optind]);
/* space and \0 */
command = realloc(command, command_length + s + 2);
command = xrealloc(command, command_length + s + 2);
endp = command + command_length;
*endp = ' ';
memcpy(endp + 1, argv[optind], s);