summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2012-08-27 09:59:13 -0400
committerPhilip Kelley <phkelley@hotmail.com>2012-08-27 09:59:13 -0400
commitc49d328cf433da1bf25a97e3935069308daf7f8d (patch)
tree70ee0e04e00db781b80994b6edb348968e150a44
parent2b175ca972f2531e5ef46d24abeb831d90033a33 (diff)
downloadlibgit2-c49d328cf433da1bf25a97e3935069308daf7f8d.tar.gz
Expose a malloc function to 3rd party ODB backends
-rw-r--r--include/git2/odb_backend.h6
-rw-r--r--src/odb.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index b812fef1..cb806978 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -26,6 +26,10 @@ struct git_odb_stream;
struct git_odb_backend {
git_odb *odb;
+ /* read and read_prefix each return to libgit2 a buffer which
+ * will be freed later. The buffer should be allocated using
+ * the function git_odb_backend_malloc to ensure that it can
+ * be safely freed later. */
int (* read)(
void **, size_t *, git_otype *,
struct git_odb_backend *,
@@ -102,6 +106,8 @@ GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *
GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync);
GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **backend_out, const char *index_file);
+GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
+
GIT_END_DECL
#endif
diff --git a/src/odb.c b/src/odb.c
index d5902840..55d434a8 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -708,6 +708,11 @@ int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oi
return error;
}
+void * git_odb_backend_malloc(git_odb_backend *backend, size_t len)
+{
+ return git__malloc(len);
+}
+
int git_odb__error_notfound(const char *message, const git_oid *oid)
{
if (oid != NULL) {