From: Junio C Hamano Date: Sun, 11 Sep 2016 21:42:38 GMT Subject: Re: [PATCH v7 06/10] pkt-line: add functions to read/write flush terminated packet streams Message-ID: In-Reply-To: Stefan Beller writes: > 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.