You can use packet_get_line to parse a single packet out of a stream and into a buffer. However, if you just want to throw away a set of packets from the stream, there's no need to even bother copying the bytes. This patch treats a NULL output buffer as a hint that the caller does not even want to see the output. We have to tweak the packet_trace call, too, since it showed the trace from the copied buffer, which now might not exist. The new code is actually more correct, though, as it shows just what we parsed, not any cruft that may have been in the output buffer before (it never mattered, though, because all callers gave us a fresh buffer). Signed-off-by: Jeff King <peff@xxxxxxxx> --- pkt-line.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkt-line.c b/pkt-line.c index eaba15f..7f28701 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -234,9 +234,10 @@ int packet_get_line(struct strbuf *out, *src_len -= 4; len -= 4; - strbuf_add(out, *src_buf, len); + if (out) + strbuf_add(out, *src_buf, len); + packet_trace(*src_buf, len, 0); *src_buf += len; *src_len -= len; - packet_trace(out->buf, out->len, 0); return len; } -- 1.8.1.2.11.g1a2f572 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html