about summary refs log tree commit diff stats
path: root/ui-snapshot.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 8b81e37..2801393 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c
@@ -13,35 +13,35 @@
13 13
14static int write_archive_type(const char *format, const char *hex, const char *prefix) 14static 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 if (fflush(stdout)) 40 if (fflush(stdout))
41 return errno; 41 return errno;
42 42
43 result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0); 43 result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0);
44 argv_array_clear(&argv); 44 strvec_clear(&argv);
45 free(nargv); 45 free(nargv);
46 return result; 46 return result;
47} 47}