const gchar* vs gchar *
Geert Janssens
janssens-geert at telenet.be
Sat Dec 22 06:51:10 EST 2012
And now a question to show that I never had a formal c/c++ education.
Are the below functions equivalent ?
void funcA ()
{
gchar *varA = g_strdup ("Test");
<do something with a>
g_free (varA);
}
and
void funcA ()
{
const gchar *varA = g_strdup ("Test");
<do something with a>
}
I'm mostly wondering if the second function would have a memory leak or
not. If varA is defined as a const gchar *, will the program
automatically free the memory allocated with g_strdup ?
I don't expect so, but I'm seeing mixed uses in GnuCash and want to
determine for once and for all what is the proper way to handle this.
Geert
More information about the gnucash-devel
mailing list