<p>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 <code>g_intern_string</code> or this:</p>
<div class="highlight highlight-source-c"><pre>    <span class="pl-k">static</span> <span class="pl-k">const</span> gchar *labels[<span class="pl-c1">10</span>];
    <span class="pl-k">int</span> n;

    <span class="pl-k">for</span> (n = <span class="pl-c1">1</span>; n != <span class="pl-c1">10</span>; n++)
        labels[n] = g_strdup_printf(_(<span class="pl-s"><span class="pl-pds">"</span>Send to Custom Command <span class="pl-c1">%d</span><span class="pl-pds">"</span></span>), n);

    <span class="pl-en">ADD_KB_CUSTOM_COMMAND</span>(<span class="pl-c1">1</span>, GDK_1, GEANY_PRIMARY_MOD_MASK);
    ...</pre></div>
<p>I think the macro is not so bad if it only wraps <code>add_kb</code> and allocation is done outside it.<br>
(It's a shame there's no <code>g_string_chunk_insert_printf</code>).</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1058#issuecomment-293511898">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ_Ly5GSN28Ij_qRWsP7uyNXvOnioks5rvI3AgaJpZM4IxerS">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJyjuVjUCsNPVqj3uA9CHIs_mJFfJks5rvI3AgaJpZM4IxerS.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1058#issuecomment-293511898"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@ntrel in #1058: 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:\r\n```c\r\n    static const gchar *labels[10];\r\n    int n;\r\n\r\n    for (n = 1; n != 10; n++)\r\n        labels[n] = g_strdup_printf(_(\"Send to Custom Command %d\"), n);\r\n\r\n    ADD_KB_CUSTOM_COMMAND(1, GDK_1, GEANY_PRIMARY_MOD_MASK);\r\n    ...\r\n```\r\nI think the macro is not so bad if it only wraps `add_kb` and allocation is done outside it.\r\n(It's a shame there's no `g_string_chunk_insert_printf`)."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1058#issuecomment-293511898"}}}</script>