Re: PATCH: cleanup + vim sets remove



On 2001.10.14 16:31 Ali Akcaagac wrote:
> On 2001.10.14 22:18:39 +0200 Peter Bloomfield wrote:
> > ...
> > >      while (list) {
> > ...
> > > +	list = g_list_next(list);
> > >      }
> > > -
> > > -    g_list_free(l);
> > > +
> > > +    g_list_free(list);
> >
> > This seems to guarantee that `list' is NULL when you get to
> > `g_list_free(list);'--is that what you really want?
> 
> l = list = g_list_append ......
> 
> same address.. no matter if i free 'list' or 'l' its the same address
> not to mention that the stuff is checked only once and then
> either its true or false and it exits.. or am i just overworked ?

l = list = g_list_append ......

Sure, they start out the same...

while (list) {
...
  list = g_list_next(list);
}

Now they're different!  The loop can't terminate until list == NULL.  
At that point, `g_list_free(l)' will free the memory, but 
`g_list_free(list)' is the same as `g_list_free(NULL)': a no-op.

Time for a beer... 




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