[plt-scheme] GC and scheme C API

From: Veer (diggerrrrr at gmail.com)
Date: Mon May 31 10:56:56 EDT 2010


Need some information on garbage collection and scheme C API.
Please correct , if following assumptions are wrong.

Assume pointers to be containing address of allocated memory by
scheme_malloc and its variant or memory address return by external
non-scheme api's , like malloc for example.

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;

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 ?

Sorry , if i got everything wrong :)


Posted on the users mailing list.