Commit Diff


commit - a440fac05e070a11112ddfdd8b655bf07c6c6bb7
commit + 03fa71c8764d610e39b7c0428ed2c51d5f0c9c20
blob - faa61ff95159f2d393bc44386a2f872609309452
blob + e8d569b12eb5b9f74cbe5fdf362abe1b0c79c118
--- lib/object.c
+++ lib/object.c
@@ -222,28 +222,6 @@ got_object_open_by_id_str(struct got_object **obj, str
 		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
 
 	return got_object_open(obj, repo, &id);
-}
-
-void
-got_object_close(struct got_object *obj)
-{
-	if (obj->refcnt > 0) {
-		obj->refcnt--;
-		if (obj->refcnt > 0)
-			return;
-	}
-
-	if (obj->flags & GOT_OBJ_FLAG_DELTIFIED) {
-		struct got_delta *delta;
-		while (!SIMPLEQ_EMPTY(&obj->deltas.entries)) {
-			delta = SIMPLEQ_FIRST(&obj->deltas.entries);
-			SIMPLEQ_REMOVE_HEAD(&obj->deltas.entries, entry);
-			got_delta_close(delta);
-		}
-	}
-	if (obj->flags & GOT_OBJ_FLAG_PACKED)
-		free(obj->path_packfile);
-	free(obj);
 }
 
 const struct got_error *
@@ -289,13 +267,6 @@ got_object_qid_alloc(struct got_object_qid **qid, stru
 	return NULL;
 }
 
-void
-got_object_qid_free(struct got_object_qid *qid)
-{
-	free(qid->id);
-	free(qid);
-}
-
 const struct got_error *
 got_object_commit_open(struct got_commit_object **commit,
     struct got_repository *repo, struct got_object *obj)
@@ -337,30 +308,6 @@ got_object_commit_open(struct got_commit_object **comm
 	return err;
 }
 
-void
-got_object_commit_close(struct got_commit_object *commit)
-{
-	struct got_object_qid *qid;
-
-	if (commit->refcnt > 0) {
-		commit->refcnt--;
-		if (commit->refcnt > 0)
-			return;
-	}
-
-	while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
-		qid = SIMPLEQ_FIRST(&commit->parent_ids);
-		SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
-		got_object_qid_free(qid);
-	}
-
-	free(commit->tree_id);
-	free(commit->author);
-	free(commit->committer);
-	free(commit->logmsg);
-	free(commit);
-}
-
 const struct got_error *
 got_object_tree_open(struct got_tree_object **tree,
     struct got_repository *repo, struct got_object *obj)
@@ -423,26 +370,6 @@ got_object_open_as_tree(struct got_tree_object **tree,
 done:
 	got_object_close(obj);
 	return err;
-}
-
-void
-got_object_tree_close(struct got_tree_object *tree)
-{
-	struct got_tree_entry *te;
-
-	if (tree->refcnt > 0) {
-		tree->refcnt--;
-		if (tree->refcnt > 0)
-			return;
-	}
-
-	while (!SIMPLEQ_EMPTY(&tree->entries.head)) {
-		te = SIMPLEQ_FIRST(&tree->entries.head);
-		SIMPLEQ_REMOVE_HEAD(&tree->entries.head, entry);
-		got_object_tree_entry_close(te);
-	}
-
-	free(tree);
 }
 
 const struct got_tree_entries *
blob - cf6560f02d84d3a42d5c5c293e1e1724f768c530
blob + 3b98216fb5dfe9e4e4624f8f9e53ed461cea01e9
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -58,6 +58,35 @@
 #define GOT_COMMIT_TAG_AUTHOR		"author "
 #define GOT_COMMIT_TAG_COMMITTER	"committer "
 
+void
+got_object_close(struct got_object *obj)
+{
+	if (obj->refcnt > 0) {
+		obj->refcnt--;
+		if (obj->refcnt > 0)
+			return;
+	}
+
+	if (obj->flags & GOT_OBJ_FLAG_DELTIFIED) {
+		struct got_delta *delta;
+		while (!SIMPLEQ_EMPTY(&obj->deltas.entries)) {
+			delta = SIMPLEQ_FIRST(&obj->deltas.entries);
+			SIMPLEQ_REMOVE_HEAD(&obj->deltas.entries, entry);
+			got_delta_close(delta);
+		}
+	}
+	if (obj->flags & GOT_OBJ_FLAG_PACKED)
+		free(obj->path_packfile);
+	free(obj);
+}
+
+void
+got_object_qid_free(struct got_object_qid *qid)
+{
+	free(qid->id);
+	free(qid);
+}
+
 static const struct got_error *
 parse_object_header(struct got_object **obj, char *buf, size_t len)
 {
@@ -359,6 +388,30 @@ parse_commit_time(struct tm *tm, char *committer)
 	return NULL;
 }
 
+void
+got_object_commit_close(struct got_commit_object *commit)
+{
+	struct got_object_qid *qid;
+
+	if (commit->refcnt > 0) {
+		commit->refcnt--;
+		if (commit->refcnt > 0)
+			return;
+	}
+
+	while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
+		qid = SIMPLEQ_FIRST(&commit->parent_ids);
+		SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
+		got_object_qid_free(qid);
+	}
+
+	free(commit->tree_id);
+	free(commit->author);
+	free(commit->committer);
+	free(commit->logmsg);
+	free(commit);
+}
+
 const struct got_error *
 got_object_parse_commit(struct got_commit_object **commit, char *buf, size_t len)
 {
@@ -479,14 +532,34 @@ done:
 	return err;
 }
 
-void
-got_object_tree_entry_close(struct got_tree_entry *te)
+static void
+tree_entry_close(struct got_tree_entry *te)
 {
 	free(te->id);
 	free(te->name);
 	free(te);
 }
 
+void
+got_object_tree_close(struct got_tree_object *tree)
+{
+	struct got_tree_entry *te;
+
+	if (tree->refcnt > 0) {
+		tree->refcnt--;
+		if (tree->refcnt > 0)
+			return;
+	}
+
+	while (!SIMPLEQ_EMPTY(&tree->entries.head)) {
+		te = SIMPLEQ_FIRST(&tree->entries.head);
+		SIMPLEQ_REMOVE_HEAD(&tree->entries.head, entry);
+		tree_entry_close(te);
+	}
+
+	free(tree);
+}
+
 struct got_tree_entry *
 got_alloc_tree_entry_partial(void)
 {
@@ -549,7 +622,7 @@ parse_tree_entry(struct got_tree_entry **te, size_t *e
 	*elen += SHA1_DIGEST_LENGTH;
 done:
 	if (err) {
-		got_object_tree_entry_close(*te);
+		tree_entry_close(*te);
 		*te = NULL;
 	}
 	return err;