diff options
author | Tim Janik <timj@gtk.org> | 2000-10-25 22:33:26 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2000-10-25 22:33:26 +0000 |
commit | 900d0ed069fe09201d0c58813d1560b6845cef1d (patch) | |
tree | 39ee33876ecf167fe9e74c9dc746862c392cd6e1 /gobject/gvaluetypes.c | |
parent | ee23c09e83d06a0d131ebd234c132f1c3602c019 (diff) |
added g_value_set_static_string().
Thu Oct 26 00:30:27 2000 Tim Janik <timj@gtk.org>
* gvaluetypes.[hc]: added g_value_set_static_string().
* gboxed.[hc]: const corrections. added g_value_set_static_boxed().
Diffstat (limited to 'gobject/gvaluetypes.c')
-rw-r--r-- | gobject/gvaluetypes.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c index 8f5d6175a..ac857bfd9 100644 --- a/gobject/gvaluetypes.c +++ b/gobject/gvaluetypes.c @@ -221,7 +221,8 @@ value_string_init (GValue *value) static void value_string_free_value (GValue *value) { - g_free (value->data[0].v_pointer); + if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG)) + g_free (value->data[0].v_pointer); } static void @@ -640,10 +641,25 @@ g_value_set_string (GValue *value, { g_return_if_fail (G_IS_VALUE_STRING (value)); - g_free (value->data[0].v_pointer); + if (value->data[1].v_uint & G_VALUE_STATIC_TAG) + value->data[1].v_uint = 0; + else + g_free (value->data[0].v_pointer); value->data[0].v_pointer = g_strdup (v_string); } +void +g_value_set_static_string (GValue *value, + const gchar *v_string) +{ + g_return_if_fail (G_IS_VALUE_STRING (value)); + + if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG)) + g_free (value->data[0].v_pointer); + value->data[1].v_uint = G_VALUE_STATIC_TAG; + value->data[0].v_pointer = (gchar*) v_string; +} + gchar* g_value_get_string (const GValue *value) { |