diff options
| author | René Scharfe <l.s.r@web.de> | 2020-02-09 16:58:42 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-02-10 09:45:49 -0800 |
| commit | 7a9f8ca805045f5d6d59227c8cce5a3e6790b0ef (patch) | |
| tree | 689b2b2dfba7c9ce7fedcee728bff69edb34a5bc | |
| parent | c84078573e9dc4b817d8270268583251eed7cff9 (diff) | |
| download | git-7a9f8ca805045f5d6d59227c8cce5a3e6790b0ef.tar.xz | |
parse-options: simplify parse_options_dup()
Simplify parse_options_dup() by making it a trivial wrapper of
parse_options_concat() by making use of the facts that the latter
duplicates its input as well and that appending an empty set is a no-op.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | parse-options-cb.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c index 7d56681130..a28b55be48 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -170,15 +170,9 @@ static size_t parse_options_count(const struct option *opt) struct option *parse_options_dup(const struct option *o) { - const struct option *orig = o; - struct option *opts; - size_t nr = parse_options_count(o); + struct option no_options[] = { OPT_END() }; - ALLOC_ARRAY(opts, nr + 1); - COPY_ARRAY(opts, orig, nr); - memset(opts + nr, 0, sizeof(*opts)); - opts[nr].type = OPTION_END; - return opts; + return parse_options_concat(o, no_options); } struct option *parse_options_concat(const struct option *a, |
