diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-06-19 12:08:10 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-06-20 14:09:46 -0400 |
commit | 9ceb2b27577f1be3f30edb40a45117066fc78c51 (patch) | |
tree | bc85b811b9ec25c83e3918f8cdc8c046516af953 /src/parse.c | |
parent | e062158e0a855cddcd3838fef415a7531929686b (diff) | |
download | bfs-9ceb2b27577f1be3f30edb40a45117066fc78c51.tar.xz |
bfstd: New xmemdup() function
Diffstat (limited to 'src/parse.c')
-rw-r--r-- | src/parse.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/parse.c b/src/parse.c index 5c55076..64e08cd 100644 --- a/src/parse.c +++ b/src/parse.c @@ -3666,14 +3666,11 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) { } ctx->argc = argc; - ctx->argv = malloc((argc + 1)*sizeof(*ctx->argv)); + ctx->argv = xmemdup(argv, sizeof_array(char *, argc + 1)); if (!ctx->argv) { - perror("malloc()"); + perror("xmemdup()"); goto fail; } - for (int i = 0; i <= argc; ++i) { - ctx->argv[i] = argv[i]; - } enum use_color use_color = COLOR_AUTO; if (getenv("NO_COLOR")) { |