Re: [PATCH 14/18] streaming: make the `odb_read_stream` definition public
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 21, 2025, 06:33 UTC
- Message-ID
- <aSAHq9_Wa2eXko1R@pks.im>
- In-Reply-To
- <CAOLa=ZT_VFfbfLVdvHUqK5C6k4zROLQs0Pt5rOWL_hE_BSfGeg@mail.gmail.com>
On Wed, Nov 19, 2025 at 11:27:29AM -0500, Karthik Nayak wrote:
Show 36 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/streaming.h b/streaming.h
> > index 95c2a434fa..3a850e3efc 100644
> > --- a/streaming.h
> > +++ b/streaming.h
> > @@ -6,11 +6,24 @@
> >
> > #include "object.h"
> >
> > -/* opaque */
> > struct object_database;
> > struct odb_read_stream;
> > struct stream_filter;
> >
> > +typedef int (*odb_read_stream_close_fn)(struct odb_read_stream *);
> > +typedef ssize_t (*odb_read_stream_read_fn)(struct odb_read_stream *, char *, size_t);
> > +
> > +/*
> > + * A stream that can be used to read an object from the object database without
> > + * loading all of it into memory.
> > + */
> > +struct odb_read_stream {
> > + odb_read_stream_close_fn close;
> > + odb_read_stream_read_fn read;
> > + enum object_type type;
> > + unsigned long size; /* inflated size of full object */
> > +};
> > +
> > struct odb_read_stream *open_istream(struct repository *, const struct object_id *,
> > enum object_type *, unsigned long *,
> > struct stream_filter *);
> >
>
> If we're returning an `struct odb_read_stream` anyways, why take in
> pointers for object size and object type? They'll be the same as
> `odb_read_stream.type` and `odb_read_stream.size` no?Yeah, they are now, so we could change it. But I wasn't really sure whether this is all that useful in the first place, and didn't quite feel like doing another tree-wide change.
But I did the change now, and I think it's a net improvement. So let me add it as another patch at the end of this series.
Thanks for your review!
Patrick