Commit fa2f6902709b3373f9da09bd711b660eeaf6e48c

Stefan Sperling 2018-07-23T11:30:26

use got_object_qid_free() consistently

diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 3942b1d..c4a7d14 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -214,7 +214,7 @@ add_vertex(struct got_object_id_queue *ids, struct got_object_id *id)
 	qid->id = got_object_id_dup(id);
 	if (qid->id == NULL) {
 		const struct got_error *err = got_error_from_errno();
-		free(qid);
+		got_object_qid_free(qid);
 		return err;
 	}
 
@@ -263,12 +263,12 @@ 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);
+		got_object_qid_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);
+		got_object_qid_free(pid);
 	}
 	free(node);
 }
@@ -280,7 +280,7 @@ add_node(struct got_commit_graph_node **new_node,
 {
 	const struct got_error *err = NULL;
 	struct got_commit_graph_node *node, *existing_node;
-	struct got_object_qid *qid;
+	struct got_object_qid *pid;
 
 	*new_node = NULL;
 
@@ -291,8 +291,8 @@ add_node(struct got_commit_graph_node **new_node,
 	memcpy(&node->id, commit_id, sizeof(node->id));
 	SIMPLEQ_INIT(&node->parent_ids);
 	SIMPLEQ_INIT(&node->child_ids);
-	SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
-		err = add_vertex(&node->parent_ids, qid->id);
+	SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
+		err = add_vertex(&node->parent_ids, pid->id);
 		if (err) {
 			free_node(node);
 			return err;
diff --git a/lib/object.c b/lib/object.c
index eb8d9b4..d026b2c 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -485,7 +485,7 @@ got_object_qid_alloc(struct got_object_qid **qid, struct got_object_id *id)
 	(*qid)->id = got_object_id_dup(id);
 	if ((*qid)->id == NULL) {
 		err = got_error_from_errno();
-		free(*qid);
+		got_object_qid_free(*qid);
 		*qid = NULL;
 		return err;
 	}
@@ -514,7 +514,7 @@ got_object_commit_add_parent(struct got_commit_object *commit,
 	qid->id = malloc(sizeof(*qid->id));
 	if (qid->id == NULL) {
 		err = got_error_from_errno();
-		free(qid);
+		got_object_qid_free(qid);
 		return err;
 	}
 
@@ -1039,8 +1039,7 @@ got_object_commit_close(struct got_commit_object *commit)
 	while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
 		qid = SIMPLEQ_FIRST(&commit->parent_ids);
 		SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
-		free(qid->id);
-		free(qid);
+		got_object_qid_free(qid);
 	}
 
 	free(commit->tree_id);