Re: simple question: are const gchar* arguments hold as copies internally?
- From: Tristan Van Berkom <tvb gnome org>
- To: Felix Kater <f kater2 gmx net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: simple question: are const gchar* arguments hold as copies internally?
- Date: Tue, 06 Sep 2005 10:49:20 -0400
Felix Kater wrote:
Hi,
these two functions take const gchar pointers:
void gtk_label_set_text([...] const gchar *str);
void g_key_file_set_value([...] const gchar *group_name, [...])
Does that mean that the arguments are *not* hold as copies internally
so that I have to care for the allocated memory -- or can I savely pass
a temporary character string as an argument to the functions which make
a copy of the strings internally and also release their memory when
necessary automatically?
Generally,
if a function takes `const gchar *' as an argument it just means
that the said function garauntees that your string will not be modified
by that function (whereas a `gchar *' argument is generally a return
location for a single char).
Here are some examples in GTK+ that do use static strings:
http://developer.gnome.org/doc/API/2.0/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-set-static-string
http://developer.gnome.org/doc/API/2.0/glib/glib-Quarks.html#g-quark-from-static-string
Usualy this behaviour is quite explicit :)
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]