]> granicus.if.org Git - cgit/commitdiff
Use string list strdup_strings for mimetypes
authorJohn Keeping <john@keeping.me.uk>
Wed, 20 Jun 2018 10:12:09 +0000 (18:12 +0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Jun 2018 17:28:16 +0000 (19:28 +0200)
There's no need to do this manually with the string list API will do it
for us.

Signed-off-by: John Keeping <john@keeping.me.uk>
cgit.c

diff --git a/cgit.c b/cgit.c
index 223dfc8164b913d36a97534d48ab89fb4a650a70..0c9f3e9a1b3cf854e39f8cffc432201cdd1be183 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -23,7 +23,7 @@ static void add_mimetype(const char *name, const char *value)
 {
        struct string_list_item *item;
 
-       item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name));
+       item = string_list_insert(&ctx.cfg.mimetypes, name);
        item->util = xstrdup(value);
 }
 
@@ -414,7 +414,7 @@ static void prepare_context(void)
        ctx.page.modified = time(NULL);
        ctx.page.expires = ctx.page.modified;
        ctx.page.etag = NULL;
-       memset(&ctx.cfg.mimetypes, 0, sizeof(struct string_list));
+       string_list_init(&ctx.cfg.mimetypes, 1);
        if (ctx.env.script_name)
                ctx.cfg.script_name = xstrdup(ctx.env.script_name);
        if (ctx.env.query_string)