crystal clear()

Sean Kelly sean at invisibleduck.org
Fri Sep 17 16:02:07 PDT 2010


Steven Schveighoffer Wrote:

> On Fri, 17 Sep 2010 18:31:45 -0400, Sean Kelly <sean at invisibleduck.org>  
> wrote:
> >
> > Is there some reason clear() can't just call rt_finalize?
> 
> does rt_finalize not deallocate the memory?  If so, that's probably the  
> right thing to do.  In fact, I think it does exactly what we want.  It  
> calls collectHandler, what does that mean?

call rt_finalize(p, true) (det means "deterministic", and is called when you do "delete p" for example).  The collectHandler is called when the GC finalizes something.  If the collectHandler returns false then the object's dtor will not be invoked.  So basically, collectHandler is a hook for reporting GC finalization of objects and can also affect whether the dtor is invoked by the GC for specific objects.

> I'm thinking you are right.  Why didn't you speak up before I went through  
> all this trouble? ;)

:-)


More information about the Digitalmars-d mailing list