[plt-scheme] GC and scheme C API

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 31 11:01:23 EDT 2010

At Mon, 31 May 2010 20:26:56 +0530, Veer wrote:
> Suppose i get external pointer (not scheme pointer) , and other
> function calls make use
> of this pointer .
> 
> So , what i do is make a new scheme type "<eobject>" and structure like this:
> 
> typedef struct {
>   Scheme_Object sob;
>   External_Object* eptr;
> }EObject;
> 
> and use  "scheme_malloc_tagged" ,
> GC_register_traversers(etype,e_size,e_mark,e_fixup, ....)
> and "scheme_register_finalizer" to complete the construction of
> EObject , and return it as Scheme_Object*
> 
> Is it correct to assume that :
> --  e_mark is used to tell what other pointers are in the EObject
> --  e_fixup is used to fix the marked pointers  in EObject , so that
> they can point to correct objects.
> --  finalizer func can be used to free eptr in EObject , when there
> are no reference to EObject in scheme
> 
> Since eptr is not a scheme_pointer , what role does it have in e_mark
> and e_fixup ?

If `eptr' never refers to a GCable value, then don't refer to it in the
mark or fixup function. Ignore it, the same as an integer value.



Posted on the users mailing list.