X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=parse-options-cb.c;h=1240a8514e040954cbc7f091e7053b5c76ac6627;hb=c46ebc2496dc1960b54b7e2678b2eb61000155c3;hp=a3de795c581a3aab084efac75ed2d6edc2535a15;hpb=776d668142070cd1234bcc9df6661d372cae2e16;p=thirdparty%2Fgit.git diff --git a/parse-options-cb.c b/parse-options-cb.c index a3de795c58..1240a8514e 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -159,6 +159,23 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) return 0; } +struct option *parse_options_dup(const struct option *o) +{ + struct option *opts; + int nr = 0; + + while (o && o->type != OPTION_END) { + nr++; + o++; + } + + ALLOC_ARRAY(opts, nr + 1); + memcpy(opts, o - nr, sizeof(*o) * nr); + memset(opts + nr, 0, sizeof(*opts)); + opts[nr].type = OPTION_END; + return opts; +} + struct option *parse_options_concat(struct option *a, struct option *b) { struct option *ret;