summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-07-11 22:42:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-17 22:47:48 (GMT)
commitc3756d5b7fc6e163032296aa6c10fad2589273dc (patch)
tree6436f9afe6da8f7202e62296b5393db0c1b61918 /commit-graph.c
parente5c5ca27292d302b7ccf7e44c43d8b9474513867 (diff)
downloadgit-c3756d5b7fc6e163032296aa6c10fad2589273dc.zip
git-c3756d5b7fc6e163032296aa6c10fad2589273dc.tar.gz
git-c3756d5b7fc6e163032296aa6c10fad2589273dc.tar.bz2
commit-graph: add free_commit_graph
Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 1ea701e..143a587 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -231,16 +231,8 @@ static int prepare_commit_graph(void)
static void close_commit_graph(void)
{
- if (!commit_graph)
- return;
-
- if (commit_graph->graph_fd >= 0) {
- munmap((void *)commit_graph->data, commit_graph->data_len);
- commit_graph->data = NULL;
- close(commit_graph->graph_fd);
- }
-
- FREE_AND_NULL(commit_graph);
+ free_commit_graph(commit_graph);
+ commit_graph = NULL;
}
static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t *pos)
@@ -1033,3 +1025,15 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
return verify_commit_graph_error;
}
+
+void free_commit_graph(struct commit_graph *g)
+{
+ if (!g)
+ return;
+ if (g->graph_fd >= 0) {
+ munmap((void *)g->data, g->data_len);
+ g->data = NULL;
+ close(g->graph_fd);
+ }
+ free(g);
+}