diff options
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r-- | ui-snapshot.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 556d3ed..18361a6 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -13,32 +13,32 @@ | |||
13 | 13 | ||
14 | static int write_archive_type(const char *format, const char *hex, const char *prefix) | 14 | static int write_archive_type(const char *format, const char *hex, const char *prefix) |
15 | { | 15 | { |
16 | struct argv_array argv = ARGV_ARRAY_INIT; | 16 | struct strvec argv = STRVEC_INIT; |
17 | const char **nargv; | 17 | const char **nargv; |
18 | int result; | 18 | int result; |
19 | argv_array_push(&argv, "snapshot"); | 19 | strvec_push(&argv, "snapshot"); |
20 | argv_array_push(&argv, format); | 20 | strvec_push(&argv, format); |
21 | if (prefix) { | 21 | if (prefix) { |
22 | struct strbuf buf = STRBUF_INIT; | 22 | struct strbuf buf = STRBUF_INIT; |
23 | strbuf_addstr(&buf, prefix); | 23 | strbuf_addstr(&buf, prefix); |
24 | strbuf_addch(&buf, '/'); | 24 | strbuf_addch(&buf, '/'); |
25 | argv_array_push(&argv, "--prefix"); | 25 | strvec_push(&argv, "--prefix"); |
26 | argv_array_push(&argv, buf.buf); | 26 | strvec_push(&argv, buf.buf); |
27 | strbuf_release(&buf); | 27 | strbuf_release(&buf); |
28 | } | 28 | } |
29 | argv_array_push(&argv, hex); | 29 | strvec_push(&argv, hex); |
30 | /* | 30 | /* |
31 | * Now we need to copy the pointers to arguments into a new | 31 | * Now we need to copy the pointers to arguments into a new |
32 | * structure because write_archive will rearrange its arguments | 32 | * structure because write_archive will rearrange its arguments |
33 | * which may result in duplicated/missing entries causing leaks | 33 | * which may result in duplicated/missing entries causing leaks |
34 | * or double-frees in argv_array_clear. | 34 | * or double-frees in strvec_clear. |
35 | */ | 35 | */ |
36 | nargv = xmalloc(sizeof(char *) * (argv.argc + 1)); | 36 | nargv = xmalloc(sizeof(char *) * (argv.nr + 1)); |
37 | /* argv_array guarantees a trailing NULL entry. */ | 37 | /* strvec guarantees a trailing NULL entry. */ |
38 | memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1)); | 38 | memcpy(nargv, argv.v, sizeof(char *) * (argv.nr + 1)); |
39 | 39 | ||
40 | result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0); | 40 | result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0); |
41 | argv_array_clear(&argv); | 41 | strvec_clear(&argv); |
42 | free(nargv); | 42 | free(nargv); |
43 | return result; | 43 | return result; |
44 | } | 44 | } |