Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 92859f3

Browse files
rscharfegitster
authored andcommitted
bundle: use internal argv_array of struct child_process in create_bundle()
Use the existing argv_array member instead of providing our own. This way the argv_array is cleared after use automatically for us; it was leaking before. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14576df commit 92859f3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

bundle.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ int create_bundle(struct bundle_header *header, const char *path,
237237
static struct lock_file lock;
238238
int bundle_fd = -1;
239239
int bundle_to_stdout;
240-
struct argv_array argv_boundary = ARGV_ARRAY_INIT;
241-
struct argv_array argv_pack = ARGV_ARRAY_INIT;
242240
int i, ref_count = 0;
243241
struct strbuf buf = STRBUF_INIT;
244242
struct rev_info revs;
@@ -260,14 +258,12 @@ int create_bundle(struct bundle_header *header, const char *path,
260258
init_revisions(&revs, NULL);
261259

262260
/* write prerequisites */
263-
argv_array_pushl(&argv_boundary,
261+
memset(&rls, 0, sizeof(rls));
262+
argv_array_pushl(&rls.args,
264263
"rev-list", "--boundary", "--pretty=oneline",
265264
NULL);
266265
for (i = 1; i < argc; i++)
267-
argv_array_push(&argv_boundary, argv[i]);
268-
269-
memset(&rls, 0, sizeof(rls));
270-
rls.argv = argv_boundary.argv;
266+
argv_array_push(&rls.args, argv[i]);
271267
rls.out = -1;
272268
rls.git_cmd = 1;
273269
if (start_command(&rls))
@@ -382,12 +378,11 @@ int create_bundle(struct bundle_header *header, const char *path,
382378
write_or_die(bundle_fd, "\n", 1);
383379

384380
/* write pack */
385-
argv_array_pushl(&argv_pack,
381+
memset(&rls, 0, sizeof(rls));
382+
argv_array_pushl(&rls.args,
386383
"pack-objects", "--all-progress-implied",
387384
"--stdout", "--thin", "--delta-base-offset",
388385
NULL);
389-
memset(&rls, 0, sizeof(rls));
390-
rls.argv = argv_pack.argv;
391386
rls.in = -1;
392387
rls.out = bundle_fd;
393388
rls.git_cmd = 1;

0 commit comments

Comments
 (0)