gtk.cfg: Add configurations for g_free() and g_malloc() / g_malloc0()

Reference: https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html
daca@home found these missing function configurations among others.
Also add tests for g_malloc() and g_free().
This commit is contained in:
versat 2019-01-28 13:47:46 +01:00
parent ba4a4c3395
commit 62b9368b3c
2 changed files with 34 additions and 0 deletions

View File

@ -3609,6 +3609,14 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<!-- void g_free(gpointer mem); -->
<function name="g_free">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<function name="g_hash_table_iter_get_hash_table">
<leak-ignore/>
<noreturn>false</noreturn>
@ -4009,6 +4017,17 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<!-- gpointer g_malloc(gsize n_bytes); -->
<!-- gpointer g_malloc0(gsize n_bytes); -->
<function name="g_malloc,g_malloc0">
<noreturn>false</noreturn>
<returnValue type="gpointer"/>
<arg nr="1">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<function name="g_mapped_file_get_contents">
<leak-ignore/>
<noreturn>false</noreturn>

View File

@ -23,4 +23,19 @@ void validCode(int argInt)
printf("%s", _("test"));
printf("%s", Q_("a|test"));
printf("%s", N_("test"));
gpointer gpt = g_malloc(4);
printf("%p", gpt);
g_free(gpt);
}
void g_malloc_test()
{
// cppcheck-suppress leakReturnValNotUsed
g_malloc(8);
gpointer gpt = g_malloc(1);
printf("%p", gpt);
// cppcheck-suppress memleak
}