Re: g_locale_to_utf8
- From: Tim Müller <zen18864 zen co uk>
- To: gtk-app-devel-list gnome org
- Subject: Re: g_locale_to_utf8
- Date: Mon, 10 Jan 2005 10:45:48 +0000
On Monday 10 January 2005 10:25, shakti wrote:
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.h
tml#g-strdup
You are misreading the API here. Both functions return newly-allocated
strings, and in both cases you have to g_free() the returned string when you
don't need it any longer.
Just because the g_locale_to_utf8() docs don't tell you explicitly that the
return value needs to be freed doesn't mean that you don't have to free it;
it's implicit in the type of the return value.
As a general rule: if a GLib string function returns a const gchar * then you
do not have to free it and must not modify it. If a GLib string function
returns a gchar *, then you have to free this string later.
Cheers
-Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]