Re: [PATCH v4 3/7] trace.c: move strbuf_release() out of print_trace_line()
- From
Jeff King <peff@peff.net>
- Date
- Jan 13, 2018, 07:14 UTC
- Message-ID
- <20180113071450.GA27251@sigill.intra.peff.net>
- In-Reply-To
- <20180113064949.6043-4-pclouds@gmail.com>
On Sat, Jan 13, 2018 at 01:49:45PM +0700, Nguyễn Thái Ngọc Duy wrote:
> The function is about printing a trace line, not releasing the buffer it > receives too. Move strbuf_release() back outside. This makes it easier > to see how strbuf is managed.
This is kind of a funny refactor, in that it makes the code longer. :) I think it does make things a bit more obvious, though.
Show 10 quoted lines
> diff --git a/trace.c b/trace.c
> index 9784915be1..7f3b08e148 100644
> --- a/trace.c
> +++ b/trace.c
> @@ -131,7 +131,6 @@ static void print_trace_line(struct trace_key *key, struct strbuf *buf)
> {
> strbuf_complete_line(buf);
> trace_write(key, buf->buf, buf->len);
> - strbuf_release(buf);
> }One mental note: any print_trace_line() calls for topics in flight need to be adjusted, or they will leak. Probably OK for a static function (and I don't see any in pu, nor git-for-windows, nor do I have any in my private stash of patches).
-Peff