From: "Gerardo Santana Gómez Garrido" Date: 2008-04-01T00:00:22+09:00 Subject: Re: mark, alloc and free functions in C extensions On 3/30/08, Joel VanderWerf wrote: > 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? > > > > Or sould the class B care for its own C structure only? Will Ruby's > > marking, allocation and liberation mechanism call their respective > > functions? > > > > I got confused. Thanks in advance. > > Class B needs to take care of both the A and B members, somehow, in its > mark, free, and alloc. Ruby doesn't know anything about how the structs > are related. I see. This C structure would contain pointers to database resources that I need to set free. The derived class would add another pointer. If I understood you correctly, I need to take care of all of them in the derived class' functions. Thanks Joel > > Btw, my cgen project[1] is a framework that supports defining classes > with C structs that inherit all the housekeeping stuff, not just > mark/free/alloc, but also persistence and accessors: > > [1] > http://redshift.sourceforge.net/cgen > http://redshift.sourceforge.net/cgen/lib/cgen/cshadow.html That's exactly what I would do :) I'll check it again later. -- Gerardo Santana