Re: Abuse of 'const' ?
- From: Ryan Lortie <desrt desrt ca>
- To: John Emmas <johne53 tiscali co uk>
- Cc: gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: Abuse of 'const' ?
- Date: Mon, 08 Apr 2013 09:09:44 -0400
hi John,
On 2013-04-08 04:44, John Emmas wrote:
// glib/gvariant.h
GLIB_AVAILABLE_IN_ALL
const gchar **g_variant_get_bytestring_array (GVariant *value, gsize
*length);
// glib/gvariant.c
static gpointer
g_variant_valist_get_nnp (const gchar **str, GVariant *value)
{
// some stuff
return g_variant_get_bytestring_array (value, NULL);
}
A 'const gchar **' is (in this case) an array of 'const gchar *' (ie:
const string pointers). It is the strings that are immutable. The
array itself is fully writable, and indeed you should free what
g_variant_get_bytestring_array() returns to you, using g_free().
By the same token it is therefore perfectly acceptable to pass it
through a gpointer.
Cheers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]