[PATCH 09/19] ui-plain.c: use struct strbuf instead of fmt()
John Keeping
john at keeping.me.uk
Sun Apr 7 11:30:00 CEST 2013
Signed-off-by: John Keeping <john at keeping.me.uk>
---
ui-plain.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ui-plain.c b/ui-plain.c
index 4c6cbb7..9793804 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -107,10 +107,12 @@ static int print_object(const unsigned char *sha1, const char *path)
static char *buildpath(const char *base, int baselen, const char *path)
{
+ struct strbuf buf = STRBUF_INIT;
if (path[0])
- return fmt("%.*s%s/", baselen, base, path);
+ strbuf_addf(&buf, "%.*s%s/", baselen, base, path);
else
- return fmt("%.*s/", baselen, base);
+ strbuf_addf(&buf, "%.*s/", baselen, base);
+ return strbuf_detach(&buf, NULL);
}
static void print_dir(const unsigned char *sha1, const char *base,
@@ -141,6 +143,7 @@ static void print_dir(const unsigned char *sha1, const char *base,
fullpath);
html("</li>\n");
}
+ free(fullpath);
}
static void print_dir_entry(const unsigned char *sha1, const char *base,
@@ -158,6 +161,7 @@ static void print_dir_entry(const unsigned char *sha1, const char *base,
cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
fullpath);
html("</li>\n");
+ free(fullpath);
}
static void print_dir_tail(void)
--
1.8.2.692.g17a9715
More information about the CGit
mailing list