mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-06 07:30:28 +02:00
Refactor to how struct and smob finalization works
* libguile/finalizers.h: * libguile/finalizers.c (scm_i_add_struct_finalizer): (scm_i_add_smob_finalizer): New internal API. * libguile/smob.c (scm_i_new_smob): (scm_i_new_double_smob): * libguile/struct.c (scm_i_alloc_struct): Use it.
This commit is contained in:
parent
6ffddf5dae
commit
532df66e07
4 changed files with 42 additions and 15 deletions
|
@ -319,12 +319,6 @@ scm_i_finalize_struct (struct scm_thread *thread, SCM obj)
|
|||
finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
struct_finalizer_trampoline (void *ptr, void *data)
|
||||
{
|
||||
scm_i_finalize_struct (SCM_I_CURRENT_THREAD, PTR2SCM (ptr));
|
||||
}
|
||||
|
||||
/* A struct is a sequence of words preceded by a pointer to the struct's
|
||||
vtable. The vtable reference is tagged with the struct tc3. */
|
||||
static SCM
|
||||
|
@ -337,7 +331,7 @@ scm_i_alloc_struct (scm_t_bits vtable_bits, int n_words)
|
|||
/* vtable_bits can be 0 when making a vtable vtable */
|
||||
if (vtable_bits && SCM_VTABLE_INSTANCE_FINALIZER (SCM_PACK (vtable_bits)))
|
||||
/* Register a finalizer for the newly created instance. */
|
||||
scm_i_set_finalizer (SCM2PTR (ret), struct_finalizer_trampoline, NULL);
|
||||
scm_i_add_struct_finalizer (SCM_I_CURRENT_THREAD, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue