This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Outline for Guile Generational GC


Dale Jordan writes:
 > The documentation on smobs indicates that a new instance is allocated
 > by scm_must_malloc, after which the C program must build a cell with
 > the correct type tag and a pointer to the malloc-ed memory.  There is
 > no mention whether an alternate means is allowed.

Easy, allocate it however you want and set the cdr of the smob cell to a
pointer of whatever was allocated. 
 
 > Unfortunately,
 > scm_must_malloc is used all over Guile itself, so we couldn't use it
 > directly to find smobs.  There wouldn't seem to be any restriction on
 > using it for other purposes, either.
 > 
 > We could try the value-added approach and provide a function defined as
 > 
 >    SCM *scm_make_instance(long smob_tag, scm_sizet smob_size)
 > 
 > that did the allocations and returned the cell pointer already set
 > up.  This would let us control where the memory was allocated from.
 > It would have to become the only supported way to allocate a smob
 > instance.
 > 

That's totally unacceptable, because many libraries require particular routines
to set up their data types. Just allocating the size doesn't cut it at all.

   Klaus Schilling