On Sun, Apr 07, 2013 at 02:20:26PM +0200, Jason A. Donenfeld wrote:
> On Sun, Apr 7, 2013 at 11:30 AM, John Keeping <[email protected]> wrote:
> > /* Prepend repo path to relative readme path unless tracked. */
> > - if (!ref && *ctx.repo->readme != '/')
> > - ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path,
> > - ctx.repo->readme));
> > + if (!ref && *ctx.repo->readme != '/') {
> > + struct strbuf buf = STRBUF_INIT;
> > + strbuf_addf(&buf, "%s/%s", ctx.repo->path,
> > ctx.repo->readme);
> > + ctx.repo->readme = strbuf_detach(&buf, NULL);
> > + }
>
> I do in fact see the merits of using strbuf and the purpose of this
> patch set, but OTOH, this little chunk here illustrates the downsides
> -- the extra verbosity this adds is really a bummer. Perhaps this
> could be moved into a new fmtalloc helper function, if this pattern is
> common?
That could be sensible. I didn't do that initially because a lot of the
uses are just:
allocate
format
use
free
and there is no real saving from a helper in that case, but in case
where we format an then detach the helper could be useful. I'll do that
in the reroll.
_______________________________________________
cgit mailing list
[email protected]
http://hjemli.net/mailman/listinfo/cgit