Also free them together at the end of the function. In a moment, the array version will become redundant. Managing them together makes later steps more obvious. Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> Reviewed-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- builtin/remote.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index d2b684c..d5a5a16 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1337,8 +1337,13 @@ static int prune_remote(const char *remote, int dry_run) : _("(no URL)")); delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs)); - for (i = 0; i < states.stale.nr; i++) - delete_refs[i] = states.stale.items[i].util; + for (i = 0; i < states.stale.nr; i++) { + const char *refname = states.stale.items[i].util; + + delete_refs[i] = refname; + string_list_insert(&delete_refs_list, refname); + } + if (!dry_run) { struct strbuf err = STRBUF_INIT; if (repack_without_refs(delete_refs, states.stale.nr, @@ -1346,13 +1351,10 @@ static int prune_remote(const char *remote, int dry_run) result |= error("%s", err.buf); strbuf_release(&err); } - free(delete_refs); for (i = 0; i < states.stale.nr; i++) { const char *refname = states.stale.items[i].util; - string_list_insert(&delete_refs_list, refname); - if (!dry_run) result |= delete_ref(refname, NULL, 0); @@ -1365,8 +1367,9 @@ static int prune_remote(const char *remote, int dry_run) } warn_dangling_symrefs(stdout, dangling_msg, &delete_refs_list); - string_list_clear(&delete_refs_list, 0); + free(delete_refs); + string_list_clear(&delete_refs_list, 0); free_remote_ref_states(&states); return result; } -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html