Make the name field const. (g_signal_newv): Don't keep an unnecessary

2005-09-05  Matthias Clasen  <mclasen@redhat.com>

	* gsignal.c (struct _SignalNode): Make the name field const.
	(g_signal_newv): Don't keep an unnecessary extra copy of the
	signal name around, and don't forget to free the name if
	an existing node is reused.
This commit is contained in:
Matthias Clasen 2005-09-05 19:23:32 +00:00 committed by Matthias Clasen
parent 38094ffb5c
commit 8161643a39
2 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2005-09-05 Matthias Clasen <mclasen@redhat.com>
* gsignal.c (struct _SignalNode): Make the name field const.
(g_signal_newv): Don't keep an unnecessary extra copy of the
signal name around, and don't forget to free the name if
an existing node is reused.
2005-08-31 Matthias Clasen <mclasen@redhat.com>
* gobject.c (g_object_do_class_init): Intern the signal name.

View File

@ -175,7 +175,7 @@ struct _SignalNode
/* permanent portion */
guint signal_id;
GType itype;
gchar *name;
const gchar *name;
guint destroyed : 1;
/* reinitializable portion */
@ -1123,14 +1123,14 @@ G_CONST_RETURN gchar*
g_signal_name (guint signal_id)
{
SignalNode *node;
gchar *name;
const gchar *name;
SIGNAL_LOCK ();
node = LOOKUP_SIGNAL_NODE (signal_id);
name = node ? node->name : NULL;
SIGNAL_UNLOCK ();
return name;
return (char*) name;
}
void
@ -1356,8 +1356,9 @@ g_signal_newv (const gchar *signal_name,
key.quark = g_quark_from_string (node->name);
key.signal_id = signal_id;
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key);
g_strdelimit (node->name, "_", '-');
key.quark = g_quark_from_static_string (node->name);
g_strdelimit (name, "_", '-');
node->name = g_intern_string (name);
key.quark = g_quark_from_string (name);
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key);
}
node->destroyed = FALSE;
@ -1388,6 +1389,8 @@ g_signal_newv (const gchar *signal_name,
}
SIGNAL_UNLOCK ();
g_free (name);
return signal_id;
}