On Sun, Mar 30, 2008 at 08:12:38PM +0900, Gerardo Santana G?mez Garrido wrote:
> I have a class A written in C that contains a C structure. I have
> defined the functions mark, alloc and free.
> 
> I have another class B, written in C, that derives from class A and
> adds another piece of C data.
> 
> Should the class B define mark, alloc and free functions for both,
> class A and class B, C structures?

Mark and free functions for data objects are per-object, not per-class.

How you implement mark and free is up to you, but ruby will only call
one mark function per object per GC run and will only call one free
function per object when it is being destroyed.

You can implement B's mark function in terms of A's mark function if B
contains an A:

  struct B
  {
    struct A base;
  }

  void mark_B(struct B * b)
  {
    mark_A(&b->base);
    -or-
    mark_A((struct A *)b);
  }

Paul