Re: [gtk-list] Re: Any problems with malloc functions?




Tim Janik <timj@gtk.org> writes:

> On 18 Jan 1999, Owen Taylor wrote:
> 
> > 
> > Ken Stebbings <kens@ecg.csg.mot.com> writes:
> > 
> > > I just got glib/gtk+ 1.13 and I still have problems relating to memory
> > > management, but hopefully it will be easier to track them down now. 
> > > When I compiled and ran testgtk, it coredumps right away:
> > > 
> > > (gdb) bt
> > > #0  0xc009f60c in memorymap ()
> > > #1  0xc009d654 in free ()
> > > #2  0xc1e76910 in g_free (mem=0x40003540) at gmem.c:394
> > > #3  0xc238a7dc in gtk_label_set_text_internal (label=0x40026948, 
> > >     str=0x40027198 "Gtk+ v1.1.13", str_wc=0x40027158) at gtklabel.c:224
> > > #4  0xc238aaec in gtk_label_set_text (label=0x40026948, 
> > >     str=0x7b03af08 "Gtk+ v1.1.13") at gtklabel.c:262
> > > #5  0xc238a6ec in gtk_label_new (str=0x40026948 "@\002aČ") at
> > > gtklabel.c:213
> > > #6  0x25bb0 in create_main_window () at testgtk.c:8433
> > > #7  0x25fdc in main (argc=1, argv=0x7b03ab84) at testgtk.c:8505
> > > (gdb) 
> > 
> > OK, this looks promising. Could you try the follwing
> > patch and see if it fixes the problem?
> > 
> >                                         Owen
> > 
> > Index: ChangeLog
> > ===================================================================
> > RCS file: /cvs/gnome/gtk+/ChangeLog,v
> > retrieving revision 1.933
> > diff -u -r1.933 ChangeLog
> > --- ChangeLog	1999/01/18 19:27:39	1.933
> > +++ ChangeLog	1999/01/18 20:43:00
> > @@ -1,3 +1,9 @@
> > +Mon Jan 18 15:46:14 1999  Owen Taylor  <otaylor@redhat.com>
> > +
> > +	* gtk/gtklabel.c (gtk_label_init): Initialize
> > +	label->label_wc. (We allocate labels from
> > +	a memchunk)
> > +
> 
> in what way should this be memchunk related (apart from the
> fact that _init functions should *always* initialize *all* fields
> correctly)?

OK, I was just trying to figure out how not initializing
label_wc could affect anything since I new we normally
use malloc0, and leaped to the conclusion that it was
because it was because we were using memchunks in
this case. I guess the problem is somewhere else.

(I'd say that initializing all fields is good practice,
 but there should be no practical consequences one
 way or the other)
                                     Owen


















































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