Re: [PATCH v2 1/8] odb/streaming: track write stream size in the structure
Karthik Nayak <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <CAOLa=ZTHaiARd2F7BL+uwN8ANNb6=ovfZ5v4=dMkgCY=N6qa7Q@mail.gmail.com> |
Patrick Steinhardt <[email protected]> writes: > 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] > 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]
signature.asc
(application/pgp-signature, 690 B)
-----BEGIN PGP SIGNATURE----- iQHKBAEBCgA0FiEEV85Mf2N1cQ/LZcYGPtWfJI5GjH8FAmp68KgWHGthcnRoaWsu MTg4QGdtYWlsLmNvbQAKCRA+1Z8kjkaMf4RYC/92Bn49n8nOQ2fE+oNILXQZDKWZ p2bijAB3a+clsBWBU7LuVF6cAuHFHxEuIlQPNG8gYXixbye5lY4LBxm1pW/3sIui JB8hFaG1vNznijjfEaKkPg41pp3TdhijWYOlWgwQQ8MLuElRIlOW/BrU8NgCZjup BXevvTJRLvw2ybT/vi3HCdLQwaxm2zVRiMvZ7GR8q81uW0MuBRV5d8j7rQ1kdR1j b5Vky2t8w4QC4WxtAkN5Ehp81dg2ZqiUh4U+S7mZmXsqyDQ9MQtSs2duZGAbU5ah 0NHBdDWpZN+kYQzCF9dJpI5s2EmpQP5AegbwuXAsjE3I0PjhEcpoqnSfXrXchdLK TZQd7hG7sTGiCZoE66u1WT6kT6QGIkLf2prItgJ27/59JVp5QEvFh428mQLRGrTl oxuhZFRoeymwUeZBCAgWb2kIG3MGNyZFGXBDhV4436L0agb82EY1M1CulBd0VZSA wXiceXGZ4ZVi+zmPeyeGnaibXE22mr+OMsaMJiU= =yXr+ -----END PGP SIGNATURE-----