summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-06-21 11:22:45 -0700
committerVicent Martí <vicent@github.com>2012-06-21 11:22:45 -0700
commit7e912dd659c0e45300307e77a25c7af62b76887c (patch)
tree8c5ef095a3df85632820ffe8b9bdeded66ced794 /src
parent6a9239990ac1146928d4523b8d164f8995d46ce2 (diff)
parentf95121cb4f9da6c5b06c9d0b31c2c9a969c1c09d (diff)
downloadlibgit2-7e912dd659c0e45300307e77a25c7af62b76887c.tar.gz
Merge pull request #780 from schu/cleanup
Cleanup
Diffstat (limited to 'src')
-rw-r--r--src/notes.c20
-rw-r--r--src/object.c4
2 files changed, 11 insertions, 13 deletions
diff --git a/src/notes.c b/src/notes.c
index efbdbabe..0dfd3f89 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -56,7 +56,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
error = find_subtree_in_current_level(&subtree, repo, root, target, *fanout);
if (error == GIT_EEXISTS) {
- return git_tree_lookup(out, repo, git_object_id((const git_object *)root));
+ return git_tree_lookup(out, repo, git_tree_id(root));
}
if (error < 0)
@@ -64,13 +64,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
*fanout += 2;
error = find_subtree_r(out, subtree, repo, target, fanout);
-
- /*
- * root is not ours to free, and the last subtree is the
- * one being returned => we only need to free the subtrees in-between
- */
- if (*out != subtree)
- git_tree_free(subtree);
+ git_tree_free(subtree);
return error;
}
@@ -153,7 +147,7 @@ static int manipulate_note_in_tree_r(
int current_error))
{
int error = -1;
- git_tree *subtree = NULL;
+ git_tree *subtree = NULL, *new = NULL;
char subtree_name[3];
error = find_subtree_in_current_level(
@@ -176,7 +170,7 @@ static int manipulate_note_in_tree_r(
/* An existing fanout has been found, let's dig deeper */
error = manipulate_note_in_tree_r(
- out, repo, subtree, note_oid, annotated_object_sha,
+ &new, repo, subtree, note_oid, annotated_object_sha,
fanout + 2, note_exists_cb, note_notfound_cb);
if (error < 0)
@@ -185,10 +179,12 @@ static int manipulate_note_in_tree_r(
strncpy(subtree_name, annotated_object_sha + fanout, 2);
subtree_name[2] = '\0';
- error = tree_write(out, repo, parent,
- git_object_id((const git_object *)(*out)), subtree_name, 0040000);
+ error = tree_write(out, repo, parent, git_tree_id(new),
+ subtree_name, 0040000);
+
cleanup:
+ git_tree_free(new);
git_tree_free(subtree);
return error;
}
diff --git a/src/object.c b/src/object.c
index d3673eda..14d64bef 100644
--- a/src/object.c
+++ b/src/object.c
@@ -156,8 +156,10 @@ int git_object_lookup_prefix(
type = odb_obj->raw.type;
- if (create_object(&object, type) < 0)
+ if (create_object(&object, type) < 0) {
+ git_odb_object_free(odb_obj);
return -1;
+ }
/* Initialize parent object */
git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid);