GtkBindingSignal changes




hi matthias,

can you please outline the rationale for this change:

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.

i think this needs to be backed out because:

1) this is an incompatible ABI change (gtkbindings.h):
   -  GtkBindingArg          *args;
   +  GtkBindingArg          args[1]; /* flexible array */

2) this code will blow up for n_args = 0 (gtkbindings.c):
   -  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);

3) the code is actually more memory inefficient now.
   the main use case are signal bindings with 0 args, which used up
   a single ->args=NULL (4bytes) pointer in GtkBindingSignal.
   with your change, sizeof (GtkBindingArg)==12 will be used instead.


it's usually a good idea to look up the author from the license comment and
if he's available ask for review before comitting buggy "improvements" ;)

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]