Re: [PATCH v3 02/35] pkt-line: introduce struct packet_reader
From: Jonathan Nieder <hidden>
Date: 2018-02-27 19:20:32
Brandon Williams wrote:
On 02/12, Jonathan Nieder wrote:
quoted
quoted
--- a/pkt-line.h +++ b/pkt-line.h@@ -111,6 +111,64 @@ char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size); */ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out); +struct packet_reader { + /* source file descriptor */ + int fd; + + /* source buffer and its size */ + char *src_buffer; + size_t src_len;Can or should this be a strbuf?quoted
+ + /* buffer that pkt-lines are read into and its size */ + char *buffer; + unsigned buffer_size;Likewise.This struct is setup to be a drop in replacement for the existing read_packet() family of functions. Because of this I tried to make the interface as similar as possible to make it easy to convert to using it as well as having no need to clean anything up (because the struct is really just a wrapper and doesn't own anything).
Sorry, I don't completely follow. Are you saying some callers play with the buffer, or are you saying you haven't checked? (If the latter, that's perfectly fine; I'm just trying to understand the API.) Either way, can you add some comments about ownership / who is allowed to write to it / etc to make it easier to clean up later? Thanks, Jonathan