Commit 08656af0 authored by Niels Möller's avatar Niels Möller
Browse files

(arglist_push_optarg): Use malloc + strcpy instead

of asprintf, for better portability.

Rev: src/arglist.c:1.3
parent 4cac0cb2
......@@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include "arglist.h"
......@@ -71,9 +72,15 @@ void
arglist_push_optarg(struct arglist *args,
const char *opt, const char *arg)
char *s;
size_t optlen = strlen(opt);
size_t arglen = strlen(arg);
if (asprintf(&s, "%s%s", opt, arg) < 0)
char *s = malloc(optlen + arglen + 1);
if (!s)
fatal("Virtual memory exhausted.\n");
strcpy(s, opt);
strcpy(s + optlen, arg);
arglist_push(args, s);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment