Re: [PATCH] Don't multiply by -1 when assigning memory



On Thu, 2006-01-05 at 11:22 +0100, Rodrigo Moya wrote:
> On Wed, 2006-01-04 at 20:58 +0800, James Henstridge wrote:
> > Rodrigo Moya wrote:
> > 
> > >On Wed, 2006-01-04 at 07:34 -0500, Matthias Clasen wrote:
> > >  
> > >
> > >>On Wed, 2006-01-04 at 13:18 +0100, Rodrigo Moya wrote:
> > >>    
> > >>
> > >>>Hi
> > >>>
> > >>>Attached patch fixes a problem I just found out. Running any GTK app
> > >>>showed this:
> > >>>
> > >>>GLib-ERROR **: gmem.c:143: failed to allocate 68719477360 bytes
> > >>>
> > >>>I found the culprit to be the patched function, which was multiplying by
> > >>>-1 when n_args was 0.
> > >>>
> > >>>Ok to commit to HEAD?
> > >>>      
> > >>>
> > >>No, thats not the right fix. We do want to subtract one GtkBindingArg
> > >>size from the GtkBindingSignal size there. 
> > >>
> > >>    
> > >>
> > >that's what it does for all cases, except when it is 0.
> > >  
> > >
> > What Matthias is saying is that in the case of zero args, you don't need
> > to allocate the full size of GtkBindingSignal: you don't need to
> > GtkBindingArg embedded at the end of the struct.  So the correct answer
> > would probably be:
> >   sizeof (GtkBindingSignal) + n_args * sizeof (GtkBindingArg) - sizeof
> > (GtkBindingArg)
> > 
> hmm, but if I understand it correctly, this would yield an invalid value
> when n_args = 0, since it would be:
> 
> sizeof (GtkBindingSignal) + 0 * sizeof (GtkBindingArg) - sizeof
> (GtkBindingArg)
> 
> which will be:
> 
> sizeof (GtkBindingSignal) + sizeof (GtkBindingArg)
> 
> is that what we want?
> 

actually, sizeof (GtkBindingSignal) - sizeof (GtkBindingArg)
and that is what was meant, yes. 

Anyway, I have reverted the questionable changes to the GtkBindingArg
struct now. 

Matthias








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