summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-15 00:05:44 -0700
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:51:40 +0200
commit786062639f05e361da977f3f1f6286141fa12fca (patch)
tree5dc63d86657681572376ef2bced9bb2cae8e2213 /src/commit.c
parent917f60c50bce09f789aeb927b45ba3bca5a23877 (diff)
downloadlibgit2-786062639f05e361da977f3f1f6286141fa12fca.tar.gz
Add callback to git_objects_table
This adds create and free callback to the git_objects_table so that more of the creation and destruction of objects can be table driven instead of using switch statements. This also makes the semantics of certain object creation functions consistent so that we can make better use of function pointers. This also fixes a theoretical error case where an object allocation fails and we end up storing NULL into the cache.
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/commit.c b/src/commit.c
index 2cee44cd2..3eca5b341 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -31,8 +31,10 @@ static void clear_parents(git_commit *commit)
git_vector_clear(&commit->parent_ids);
}
-void git_commit__free(git_commit *commit)
+void git_commit__free(void *_commit)
{
+ git_commit *commit = _commit;
+
clear_parents(commit);
git_vector_free(&commit->parent_ids);
@@ -166,10 +168,9 @@ int git_commit_create(
return retval;
}
-int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
+int git_commit__parse(void *_commit, const char *buffer, const char *buffer_end)
{
- const char *buffer = data;
- const char *buffer_end = (const char *)data + len;
+ git_commit *commit = _commit;
git_oid parent_id;
if (git_vector_init(&commit->parent_ids, 4, NULL) < 0)
@@ -241,13 +242,6 @@ bad_buffer:
return -1;
}
-int git_commit__parse(git_commit *commit, git_odb_object *obj)
-{
- assert(commit);
- return git_commit__parse_buffer(
- commit, git_odb_object_data(obj), git_odb_object_size(obj));
-}
-
#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
_rvalue git_commit_##_name(const git_commit *commit) \
{\