diff options
Diffstat (limited to 'command/xargs.c')
-rw-r--r-- | command/xargs.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/command/xargs.c b/command/xargs.c index 2a41460..47e0f0b 100644 --- a/command/xargs.c +++ b/command/xargs.c @@ -1,7 +1,6 @@ #include "command.h" #include "lslib.h" -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -76,7 +75,7 @@ char* read_next(FILE* file, int arg_count) { size = 0; capacity = 8; - buf = malloc(sizeof(char) * capacity); + buf = xalloc(sizeof(char) * capacity); while(c = getc(file), true) { if (c == EOF && size == 0) { @@ -86,7 +85,7 @@ char* read_next(FILE* file, int arg_count) { if (size == capacity) { capacity *= 2; - buf = realloc(buf, sizeof(char) * capacity); + buf = xrealloc(buf, sizeof(char) * capacity); } if (c == '\0' || c == EOF || (!flags.null_seperated && c == '\n')) { @@ -104,7 +103,7 @@ void read_args(FILE* file, char*** args, int* size, int* capacity) { while (arg = read_next(file, read), true) { if (*size == *capacity) { *capacity *= 2; - *args = realloc(*args, sizeof(char*) * *capacity); + *args = xrealloc(*args, sizeof(char*) * *capacity); } (*args)[(*size)++] = arg; read++; @@ -146,7 +145,7 @@ COMMAND(xargs) { size = arg_on_stack_count + 1; capacity = size + 8; - args = malloc(sizeof(char*) * capacity); + args = xalloc(sizeof(char*) * capacity); args[0] = command; memcpy(&args[1], &argv[arg_start], arg_on_stack_count * sizeof(char*)); read_args(flags.file, &args, &size, &capacity); @@ -178,7 +177,7 @@ COMMAND(xargs) { } if (execvp(command, args) == -1) { - error("error: failed to execute command: %s", strerror(errno)); + error("failed to execute command"); } cleanup: |