Re: [PATCH v2 1/8] odb/streaming: track write stream size in the structure
Patrick Steinhardt <ps@pks.im> writes:
Show 10 quoted lines
> When passing around a `struct odb_write_stream` we typically also have
> to pass the number of bytes that the stream will yield. This is required
> because the object header itself contains that size, and consequently we
> cannot write the header without that information.
>
> Move this information into the stream itself so that it becomes self-
> describing. In addition to that, this also brings the `struct
> odb_write_stream` a bit closer to the `struct odb_read_stream` so that
> we can eventually merge both stream types.
>
Okay, so this will be similar to `odb_read_stream.size`. Makes sense.
[snip]
Show 23 quoted lines
> diff --git a/odb/streaming.c b/odb/streaming.c
> index 20531e864c..38c2f6687c 100644
> --- a/odb/streaming.c
> +++ b/odb/streaming.c
> @@ -336,5 +336,6 @@ void odb_write_stream_from_fd(struct odb_write_stream *stream, int fd,
>
> stream->data = data;
> stream->read = read_object_fd;
> + stream->size = size;
> stream->is_finished = 0;
> }
> diff --git a/odb/streaming.h b/odb/streaming.h
> index c023671780..4d7d31b5aa 100644
> --- a/odb/streaming.h
> +++ b/odb/streaming.h
> @@ -55,6 +55,7 @@ ssize_t odb_read_stream_read(struct odb_read_stream *stream, void *buf, size_t l
> struct odb_write_stream {
> ssize_t (*read)(struct odb_write_stream *, unsigned char *, size_t);
> void *data;
> + size_t size;
> int is_finished;
> };
>Okay so this is the main change. Looks good.
[snip]