commit e2e879a0865a8984188e95cb05b86191c8cfd59b from: Stefan Sperling date: Mon Mar 11 16:02:19 2019 UTC introduce got_ref_list_free() and use it in got and tog commit - d0eebce407bebae4a055cc39f9d54695533b4265 commit + e2e879a0865a8984188e95cb05b86191c8cfd59b blob - 35d5afb09c6b15cffc6e6456f777c0f691a1ec6a blob + 0e10c1f50cce74da7725fe1a23d46eafa730aa8b --- got/got.c +++ got/got.c @@ -945,6 +945,7 @@ done: if (error == NULL) error = repo_error; } + got_ref_list_free(&refs); return error; } @@ -1704,6 +1705,7 @@ list_refs(struct got_repository *repo) free(refstr); } + got_ref_list_free(&refs); return NULL; } blob - f5c67f29ec81ad8f3e403e7ed93087b2c9ca2bb6 blob + 239c9dff0f4d146d3ebd9391879d1b2ef9d9ef70 --- include/got_reference.h +++ include/got_reference.h @@ -74,6 +74,9 @@ SIMPLEQ_HEAD(got_reflist_head, got_reflist_entry); const struct got_error *got_ref_list(struct got_reflist_head *, struct got_repository *); +/* Free all references on a ref list. */ +void got_ref_list_free(struct got_reflist_head *); + /* Write a reference to its on-disk path in the repository. */ const struct got_error *got_ref_write(struct got_reference *, struct got_repository *); blob - ae3b86b9ada95fc112444d7ffd884314f46f1821 blob + f66bd478a3c05946cd2b7a0efb4a82334c51fad0 --- lib/reference.c +++ lib/reference.c @@ -702,6 +702,21 @@ done: return err; } +void +got_ref_list_free(struct got_reflist_head *refs) +{ + struct got_reflist_entry *re; + + while (!SIMPLEQ_EMPTY(refs)) { + re = SIMPLEQ_FIRST(refs); + SIMPLEQ_REMOVE_HEAD(refs, entry); + got_ref_close(re->ref); + free(re->id); + free(re); + } + +} + const struct got_error * got_ref_write(struct got_reference *ref, struct got_repository *repo) { blob - 421f8fec3c395f952fa3c5a0cbccf23b54987d4b blob + 9086729bcf1c9da133572ae170a74f7d089b3b81 --- tog/tog.c +++ tog/tog.c @@ -1923,6 +1923,7 @@ done: got_repo_close(repo); if (worktree) got_worktree_close(worktree); + got_ref_list_free(&refs); return error; } @@ -2517,6 +2518,7 @@ cmd_diff(int argc, char *argv[]) error = view_loop(view); done: got_repo_close(repo); + got_ref_list_free(&refs); return error; } @@ -3288,6 +3290,7 @@ done: got_worktree_close(worktree); if (repo) got_repo_close(repo); + got_ref_list_free(&refs); return error; } @@ -3938,6 +3941,7 @@ done: got_object_tree_close(tree); if (repo) got_repo_close(repo); + got_ref_list_free(&refs); return error; }