Re: [PATCH v7 06/10] pkt-line: add functions to read/write flush terminated packet streams
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 11, 2016, 21:42 UTC
- Message-ID
- <xmqq4m5m865t.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kYHX6-hhKW_6JEd1hBNi8R+sBY-RjZARfHDMnyLKFZnsQ@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 7 quoted lines
> So as a caller the strbuf is in a different state in case of error > depending whether > the strbuf already had some data in it. I think it would be better if > we only did > `strbuf_setlen(sb_out, oldlen);` here, such that the caller can > strbuf_release it > unconditionally.
If the caller _knows_ that the strbuf is no longer needed, it can unconditionally call strbuf_release() on it, whether its buffer was already released or only its length was set to 0, no?
The callee is merely trying to be nice by resetting the strbuf to a state close to the original in the error return codepath, I would think. It may be debatable if such a niceness is needed, but it is a different matter that does not relate to the burden imposed on the caller.