[plt-scheme] Preventing GC on Scheme_Object

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sat Feb 9 11:40:36 EST 2008

I'm not sure how scheme_dont_gc_ptr works, but I doubt whether it works 
with objects with structure (like procedure in your case).

Anyway, for preventing anything from being GCed, I would either use  
MZ_GC_DECL_REG, MZ_GC_VAR_IN_REG, MZ_GC_REG and so on, or use --xform. 
Hope this helps you.

Chongkai


Vijay Mathew wrote:
> I have an extention for mzscheme in C++.
>
> This is how my code looks like:
>
> struct Widget
> {
>     Scheme_Object* callback;
>    
>     Widget() : callback(scheme_null) { }
> };
>
>
> Scheme_Object* callback(int argc, Scheme_Object** argv)
> {
>     Widget* w = new Widget;
>     w->callback = argv[0];
>     return scheme_true;
> }
>
> argv[0] is a procedure assigned from scheme code.
> This is getting garbage collected when i call (collect-garbage) even 
> though a reference is held in w->callback.
> I want to tell the GC about this reference.
> scheme_dont_gc_ptr(argv[0]) did not help.
>
> thanks,
>
>  -- Vijay
> ------------------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   


Posted on the users mailing list.