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: Smob documentation


Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:

> You should not block GC above, but instead make sure that the hash
> table can be reached by the GC, e.g.:
> 
> {
>   eval_environment_smob = scm_make_environment(eval_environment);
>   eval_environment->memoized =
>     scm_make_doubly_weak_hash_table((SCM) SCM_MAKINUM (scm_symhash_dim));
> }
> 
> eval_environment_smob can be seen by the GC because since because it
> is returned by the function it has to stay on the stack or in some
> CPU register (which will be pushed onto the stack during GC).


Hmm, that means that the following should work also:


[...]
  {
    SCM memoized = scm_make_doubly_weak_hash_table(...);
    eval_environment->memoized = memoized;
    eval_environment_smob = scm_make_environment(eval_environment);
  }
  return eval_environment_smob;
}


Jost

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