Guilev2 has little qualms calling mark/print even after freeing a smob.
So we clean out the pointer to smob data when freeing/unregistering it,
and let the mark/print trampolines detect this condition and punt.
SCM
Smob_base<Super>::mark_trampoline (SCM arg)
{
SCM
Smob_base<Super>::mark_trampoline (SCM arg)
{
- return (Super::unsmob (arg))->mark_smob ();
+ Super *ptr = Super::unsmob (arg);
+ if (ptr)
+ return ptr->mark_smob ();
+ return SCM_UNDEFINED;
}
template <class Super>
int
Smob_base<Super>::print_trampoline (SCM arg, SCM port, scm_print_state *p)
{
}
template <class Super>
int
Smob_base<Super>::print_trampoline (SCM arg, SCM port, scm_print_state *p)
{
- return (Super::unsmob (arg))->print_smob (port, p);
+ Super *ptr = Super::unsmob (arg);
+ if (ptr)
+ return ptr->print_smob (port, p);
+ return 0;
{
Super *p = Super::unchecked_unsmob (obj);
scm_gc_unregister_collectable_memory (p, sizeof (*p), smob_name_.c_str ());
{
Super *p = Super::unchecked_unsmob (obj);
scm_gc_unregister_collectable_memory (p, sizeof (*p), smob_name_.c_str ());
+ SCM_SET_SMOB_DATA (obj, static_cast<Super *> (0));