summaryrefslogtreecommitdiff
path: root/src/blob.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/blob.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/blob.c')
-rw-r--r--src/blob.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/blob.c b/src/blob.c
index 732b0f3de..501c13d1a 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -35,17 +35,17 @@ int git_blob__getbuf(git_buf *buffer, git_blob *blob)
git_odb_object_size(blob->odb_object));
}
-void git_blob__free(git_blob *blob)
+void git_blob__free(void *blob)
{
- git_odb_object_free(blob->odb_object);
+ git_odb_object_free(((git_blob *)blob)->odb_object);
git__free(blob);
}
-int git_blob__parse(git_blob *blob, git_odb_object *odb_obj)
+int git_blob__from_odb_object(void *blob, git_odb_object *odb_obj)
{
assert(blob);
git_cached_obj_incref((git_cached_obj *)odb_obj);
- blob->odb_object = odb_obj;
+ ((git_blob *)blob)->odb_object = odb_obj;
return 0;
}