Make the args a flexible array inside the struct, and allocate them

2005-12-27  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkbindings.h (GtkBindingSignal):
	* gtk/gtkbindings.c (binding_signal_new): Make the
	args a flexible array inside the struct, and allocate them
	together.
This commit is contained in:
Matthias Clasen 2005-12-28 04:09:18 +00:00 committed by Matthias Clasen
parent c70c8cf69a
commit c63a3dccab
4 changed files with 23 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2005-12-27 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkbindings.h (GtkBindingSignal):
* gtk/gtkbindings.c (binding_signal_new): Make the
args a flexible array inside the struct, and allocate them
together.
Wed Dec 28 00:45:46 2005 Tim Janik <timj@gtk.org>
* gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not

View File

@ -1,3 +1,10 @@
2005-12-27 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkbindings.h (GtkBindingSignal):
* gtk/gtkbindings.c (binding_signal_new): Make the
args a flexible array inside the struct, and allocate them
together.
Wed Dec 28 00:45:46 2005 Tim Janik <timj@gtk.org>
* gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not

View File

@ -65,11 +65,10 @@ binding_signal_new (const gchar *signal_name,
{
GtkBindingSignal *signal;
signal = g_new (GtkBindingSignal, 1);
signal = (GtkBindingSignal *) g_malloc0 (sizeof (GtkBindingSignal) + (n_args - 1) * sizeof (GtkBindingArg));
signal->next = NULL;
signal->signal_name = g_intern_string (signal_name);
signal->signal_name = (gchar *)g_intern_string (signal_name);
signal->n_args = n_args;
signal->args = g_new0 (GtkBindingArg, n_args);
return signal;
}
@ -84,7 +83,6 @@ binding_signal_free (GtkBindingSignal *sig)
if (G_TYPE_FUNDAMENTAL (sig->args[i].arg_type) == G_TYPE_STRING)
g_free (sig->args[i].d.string_data);
}
g_free (sig->args);
g_free (sig);
}

View File

@ -74,14 +74,6 @@ struct _GtkBindingEntry
GtkBindingSignal *signals;
};
struct _GtkBindingSignal
{
GtkBindingSignal *next;
gchar *signal_name;
guint n_args;
GtkBindingArg *args;
};
struct _GtkBindingArg
{
GType arg_type;
@ -92,6 +84,13 @@ struct _GtkBindingArg
} d;
};
struct _GtkBindingSignal
{
GtkBindingSignal *next;
gchar *signal_name;
guint n_args;
GtkBindingArg args[1]; /* flexible array */
};
/* Application-level methods */