commit - c336f88938f60b7e0ec2b0200d9c901ddeeec114
commit + fb5b9d5a63582091c4d5483cdb90c37ed0846329
blob - 3f3c93d30e6756de11caed8259c059c391039eb2
blob + 3942b1d52d713c06359f5bdf4d50f89f4592e602
--- lib/commit_graph.c
+++ lib/commit_graph.c
return NULL;
}
+static void
+free_node(struct got_commit_graph_node *node)
+{
+ while (!SIMPLEQ_EMPTY(&node->child_ids)) {
+ struct got_object_qid *child = SIMPLEQ_FIRST(&node->child_ids);
+ SIMPLEQ_REMOVE_HEAD(&node->child_ids, entry);
+ free(child);
+ }
+ while (!SIMPLEQ_EMPTY(&node->parent_ids)) {
+ struct got_object_qid *pid = SIMPLEQ_FIRST(&node->parent_ids);
+ SIMPLEQ_REMOVE_HEAD(&node->parent_ids, entry);
+ free(pid);
+ }
+ free(node);
+}
+
static const struct got_error *
add_node(struct got_commit_graph_node **new_node,
struct got_commit_graph *graph, struct got_object_id *commit_id,
SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
err = add_vertex(&node->parent_ids, qid->id);
if (err) {
- free(node);
+ free_node(node);
return err;
}
node->nparents++;
}
node->commit_timestamp = mktime(&commit->tm_committer);
if (node->commit_timestamp == -1) {
- free(node);
+ free_node(node);
return got_error_from_errno();
}
*new_node = node;
} else if (err->code == GOT_ERR_OBJ_EXISTS) {
err = NULL;
- free(node);
+ free_node(node);
node = existing_node;
} else {
- free(node);
+ free_node(node);
return err;
}
if (err) {
free_node:
if (node != existing_node)
- free(node);
+ free_node(node);
*new_node = NULL;
}
return err;
}
static void
-free_graph_node(struct got_object_id *id, void *data, void *arg)
+free_node_iter(struct got_object_id *id, void *data, void *arg)
{
struct got_commit_graph_node *node = data;
- while (!SIMPLEQ_EMPTY(&node->child_ids)) {
- struct got_object_qid *child = SIMPLEQ_FIRST(&node->child_ids);
- SIMPLEQ_REMOVE_HEAD(&node->child_ids, entry);
- free(child);
- }
- while (!SIMPLEQ_EMPTY(&node->parent_ids)) {
- struct got_object_qid *pid = SIMPLEQ_FIRST(&node->parent_ids);
- SIMPLEQ_REMOVE_HEAD(&node->parent_ids, entry);
- free(pid);
- }
- free(node);
+ free_node(node);
}
void
got_commit_graph_close(struct got_commit_graph *graph)
{
got_object_idset_free(graph->open_branches);
- got_object_idset_for_each(graph->node_ids, free_graph_node, NULL);
+ got_object_idset_for_each(graph->node_ids, free_node_iter, NULL);
got_object_idset_free(graph->node_ids);
free(graph);
}