-
Hi, Odb backend needs to implenment two kinds of git_odb_stream, read and write. When I create my raw::git_odb_stream {
backend,
mode: raw::GIT_STREAM_RDONLY,
hash_ctx: ptr::null_mut(), // here is a null
declared_size: 0,
write: None,
finalize_write: None,
read: Some(git_odb_stream_read), // c callback
free: Some(git_odb_stream_free), // c callback
received_bytes: 0,
}, But I eventully got an error from the floowing code in odb.c void git_odb_stream_free(git_odb_stream *stream)
{
if (stream == NULL)
return;
git_hash_ctx_cleanup(stream->hash_ctx); // hash_ctx is null
git__free(stream->hash_ctx);
stream->free(stream);
} I checked odb.c, and found out void git_odb_stream_free(git_odb_stream *stream)
{
if (stream == NULL)
return;
if (stream->hash_ctx)
git_hash_ctx_cleanup(stream->hash_ctx);
git__free(stream->hash_ctx);
stream->free(stream);
} If this is not allowed and hash_ctx is required anyway, I have to make a way to create a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hmm, really good question. This seems like we've definitely leaked out some core implementation details that shouldn't be something that consumers should be touching. read/write streams are not mandatory (libgit2 will wrap your normal, non-streaming read and write- functions with streaming proxies that will buffer). And because of that, I suspect that this oversight exists. I think that the proper solution is for |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hmm, really good question. This seems like we've definitely leaked out some core implementation details that shouldn't be something that consumers should be touching. read/write streams are not mandatory (libgit2 will wrap your normal, non-streaming read and write- functions with streaming proxies that will buffer). And because of that, I suspect that this oversight exists.
I think that the proper solution is for
git_odb_stream
to not actually have thehash_ctx
member at all. (You'll run into the same problem if / when you try to build an odb write stream, I would expect?) But we can take your fix for a quick win while we untangle this.