From c63a3dccab99bf2f43d116a46c211a4fe35ef4b6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 28 Dec 2005 04:09:18 +0000 Subject: [PATCH] Make the args a flexible array inside the struct, and allocate them 2005-12-27 Matthias Clasen * gtk/gtkbindings.h (GtkBindingSignal): * gtk/gtkbindings.c (binding_signal_new): Make the args a flexible array inside the struct, and allocate them together. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ gtk/gtkbindings.c | 6 ++---- gtk/gtkbindings.h | 15 +++++++-------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c90179d15..1d4dcff26f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-27 Matthias Clasen + + * 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 * gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 1c90179d15..1d4dcff26f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2005-12-27 Matthias Clasen + + * 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 * gtk/gtkctree.c (row_delete): delete GtkCTreeRow as GtkCTreeRow, not diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c index 1aa26eb8d0..a6afdc8e90 100644 --- a/gtk/gtkbindings.c +++ b/gtk/gtkbindings.c @@ -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); } diff --git a/gtk/gtkbindings.h b/gtk/gtkbindings.h index 8c479f9ce0..debd6989b8 100644 --- a/gtk/gtkbindings.h +++ b/gtk/gtkbindings.h @@ -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 */