Re: g_locale_to_utf8



Hi,

You have to free the return value of g_strdup() but not the return value
of g_locale_to_utf8() function.

Have a look at:

http://developer.gimp.org/api/2.0/glib/glib-Character-Set-Conversion.html#g-locale-to-utf8
http://developer.gnome.org/doc/API/2.0/glib/glib-String-Utility-Functions.html#g-strdup

no, you are wrong. You have to free what g_locale_to_utf8() returns, since
it returns "gchar*" and not "const gchar*".

hs


Andreas Volz wrote:

Hi,

I've a question how to use the return of the g_locale_to_utf8 function.
For example I've this code:

----------------------
gchar *s;
gchar *string;

string = g_strdup ("hallo");

s = g_locale_to_utf8 (string,-1,0,0,0);
g_print ("%s\n", s);
free (string);
-----------------------

Or should I do:

...
s = g_strdup (g_locale_to_utf8 (string,-1,0,0,0));
g_print ("%s\n", s);
free (string);
free (s);



Both are correct because you are freeing the return value of g_strdup(),
not g_locale_to_utf8().

Thanks,
Shakti

As I think it's the second version, but I'm not sure. Can you help me?

regards
Andreas
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]