[PATCH 10/19] ui-refs.c: use struct strbuf instead of fixed-size buffers

Jason A. Donenfeld Jason at zx2c4.com
Sun Apr 7 15:08:04 CEST 2013


On Sun, Apr 7, 2013 at 11:30 AM, John Keeping <john at keeping.me.uk> wrote:
> @@ -122,13 +124,14 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)
>         for (f = cgit_snapshot_formats; f->suffix; f++) {
>                 if (!(repo->snapshots & f->bit))
>                         continue;
> -               filename = fmt("%s%s", ref, f->suffix);
> -               cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
> +               strbuf_addf(&filename, "%s%s", ref, f->suffix);
> +               cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf);
>                 html("  ");
>         }

You need to call strbuf_reset inside that loop. Otherwise the
filenames will be concatenated for each type.




More information about the CGit mailing list