[Github-comments] [geany/geany] Use a format string instead of repeating almost the same string 9 times (#1058)

Nick Treleaven notifications at xxxxx
Wed Apr 12 08:39:28 UTC 2017


I don't think we should leak memory without holding a static pointer root to it, otherwise Valgrind will report it as definitely lost (rather than possibly lost). So if we want this then either `g_intern_string` or this:
```c
    static const gchar *labels[10];
    int n;

    for (n = 1; n != 10; n++)
        labels[n] = g_strdup_printf(_("Send to Custom Command %d"), n);

    ADD_KB_CUSTOM_COMMAND(1, GDK_1, GEANY_PRIMARY_MOD_MASK);
    ...
```
I think the macro is not so bad if it only wraps `add_kb` and allocation is done outside it.
(It's a shame there's no `g_string_chunk_insert_printf`).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1058#issuecomment-293511898
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20170412/0d6351f1/attachment.html>


More information about the Github-comments mailing list