Re: [Re: [Re: gobject weak references]]
- From: Dave Benson <daveb idealab com>
- To: Murray Cumming <murrayc usa net>
- Cc: Alex Larsson <alexl redhat com>, Sven Neumann <sven gimp org>, gtk-devel-list gnome org
- Subject: Re: [Re: [Re: gobject weak references]]
- Date: Tue, 18 Sep 2001 09:44:32 -0700
On Tue, Sep 18, 2001 at 05:10:21PM +0100, Murray Cumming wrote:
> Alex Larsson <alexl redhat com> wrote:
> > On 18 Sep 2001, Murray Cumming wrote:
> > > Sven Neumann <sven gimp org> wrote:
> > > > Hi,
> > > >
> > > > Murray Cumming <Murray_Cumming betaresearch de> writes:
> > > >
> > > > > Actually I think that your example is a bit hackish. I would prefer
> > > > > use an ID that's passed through data or is stored in the object's
> > > > > quark-data-thing mechanism. If there's no absolute need to use an
> > > > > invalid pointer then we shouldn't give people the opportunity.
> > > >
> > > > I don't think it is hackish at all. The pointer is not invalid, it's
> > > > only not pointing to a functional GObject anymore since the GObject
> > > > is in the process of being finalized when the notifier is being called.
> > > > Why would you want to add the overhead of an ID mechanism if there
> > > > already is a perfectly valid ID, the memory address of the GObject?
> > >
> > > Oh, OK, if the memory hasn't been freed yet then I have no problem with
> > > the pointer.
> > In what way does it matter if it has been freed or not?
> I wouldn't like an API to encourage the use of invalid pointers because that
> increases the chance of segfaults.
worse, if the memory has been freed then its possible
that its possible that another will get the same memory
address. so if you're using it as a key in a hash-table,
you could get a collision if the memory was freed before
the finalize hooks.
] [Thread Prev