commit - a440fac05e070a11112ddfdd8b655bf07c6c6bb7
commit + 03fa71c8764d610e39b7c0428ed2c51d5f0c9c20
blob - faa61ff95159f2d393bc44386a2f872609309452
blob + e8d569b12eb5b9f74cbe5fdf362abe1b0c79c118
--- lib/object.c
+++ lib/object.c
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 *
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)
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)
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
#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)
{
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)
{
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)
{
*elen += SHA1_DIGEST_LENGTH;
done:
if (err) {
- got_object_tree_entry_close(*te);
+ tree_entry_close(*te);
*te = NULL;
}
return err;