Skip to content

Commit 6a09c3a

Browse files
avargitster
authored andcommitted
sequencer.c: split up sequencer_remove_state()
Split off the free()-ing in sequencer_remove_state() into a utility function, which will be adjusted and called independent of the other code in sequencer_remove_state() in a subsequent commit. The only functional change here is changing the "int" to a "size_t", which is the correct type, as "xopts_nr" is a "size_t". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 01fd5fb commit 6a09c3a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

sequencer.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,22 @@ static const char *gpg_sign_opt_quoted(struct replay_opts *opts)
351351
return buf.buf;
352352
}
353353

354+
static void replay_opts_release(struct replay_opts *opts)
355+
{
356+
free(opts->gpg_sign);
357+
free(opts->reflog_action);
358+
free(opts->default_strategy);
359+
free(opts->strategy);
360+
for (size_t i = 0; i < opts->xopts_nr; i++)
361+
free(opts->xopts[i]);
362+
free(opts->xopts);
363+
strbuf_release(&opts->current_fixups);
364+
}
365+
354366
int sequencer_remove_state(struct replay_opts *opts)
355367
{
356368
struct strbuf buf = STRBUF_INIT;
357-
int i, ret = 0;
369+
int ret = 0;
358370

359371
if (is_rebase_i(opts) &&
360372
strbuf_read_file(&buf, rebase_path_refs_to_delete(), 0) > 0) {
@@ -373,14 +385,7 @@ int sequencer_remove_state(struct replay_opts *opts)
373385
}
374386
}
375387

376-
free(opts->gpg_sign);
377-
free(opts->reflog_action);
378-
free(opts->default_strategy);
379-
free(opts->strategy);
380-
for (i = 0; i < opts->xopts_nr; i++)
381-
free(opts->xopts[i]);
382-
free(opts->xopts);
383-
strbuf_release(&opts->current_fixups);
388+
replay_opts_release(opts);
384389

385390
strbuf_reset(&buf);
386391
strbuf_addstr(&buf, get_dir(opts));

0 commit comments

Comments
 (0)