From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Sun, 7 Apr 2013 14:20:26 +0200 Subject: [PATCH 14/19] ui-summary.c: use struct strbuf instead of fixed-size buffers In-Reply-To: <4dd4fc55af2528bc676893c2bff8163d7f7d21d5.1365326321.git.john@keeping.me.uk> References: <4dd4fc55af2528bc676893c2bff8163d7f7d21d5.1365326321.git.john@keeping.me.uk> Message-ID: On Sun, Apr 7, 2013 at 11:30 AM, John Keeping 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?