Re: [PATCH 10/67] mailsplit: make PATH_MAX buffers dynamic
- From
Jeff King <peff@peff.net>
- Date
- Sep 16, 2015, 20:22 UTC
- Message-ID
- <20150916202254.GA3915@sigill.intra.peff.net>
- In-Reply-To
- <xmqqpp1iqlke.fsf@gitster.mtv.corp.google.com>
On Wed, Sep 16, 2015 at 11:13:37AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> Jeff King <peff@peff.net> writes:
>
> > + free(file);
> > + file = xstrfmt("%s/%s", maildir, list.items[i].string);
>
> Repeated pattern makes one wonder if a thin wrapper
>
> xstrfmt_to(&file, "%s/%s", maildir, list.items[i].string);
>
> that first frees the existing value and then overwrites is an
> overall win. Perhaps not, as you would (1) initialize the variable
> to NULL before doing a series of xstrfmt_to(), and (2) free the final
> one yourself.Yeah, exactly. If you want to wrap it up in something that understands invariants, I think strbuf is the way to go. I dunno. Maybe I should just have done this whole thing with strbufs.
-Peff