summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-08-15 13:48:35 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2013-08-15 14:29:27 +0200
commit376e6c9f96ffcd572ba974c9cc4d13b4f1e31474 (patch)
tree8f8cfb27e725e962e3c7cec5e7fa2c4bfa2987bd /src/odb.c
parent2af9bcb2dbb47adafa7eecbf41ff113da7fa9d1b (diff)
downloadlibgit2-376e6c9f96ffcd572ba974c9cc4d13b4f1e31474.tar.gz
odb: wrap the stream reading and writing functions
This is in preparation for moving the hashing to the frontend, which requires us to handle the incoming data before passing it to the backend's stream.
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/odb.c b/src/odb.c
index 6969cf772..158159662 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -864,9 +864,9 @@ int git_odb_write(
if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0)
return error;
- stream->write(stream, data, len);
- error = stream->finalize_write(oid, stream);
- stream->free(stream);
+ git_odb_stream_write(stream, data, len);
+ error = git_odb_stream_finalize_write(oid, stream);
+ git_odb_stream_free(stream);
return error;
}
@@ -904,6 +904,26 @@ int git_odb_open_wstream(
return error;
}
+int git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len)
+{
+ return stream->write(stream, buffer, len);
+}
+
+int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream)
+{
+ return stream->finalize_write(out, stream);
+}
+
+int git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len)
+{
+ return stream->read(stream, buffer, len);
+}
+
+void git_odb_stream_free(git_odb_stream *stream)
+{
+ stream->free(stream);
+}
+
int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid)
{
size_t i, reads = 0;