2 smobs.cc -- implement Smob protection
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 static SCM smob_protection_list;
15 init_smob_protection()
17 smob_protection_list = scm_cons (SCM_UNDEFINED, SCM_EOL);
18 scm_permanent_object (smob_protection_list);
20 ADD_SCM_INIT_FUNC(init_smob_protection, init_smob_protection);
23 protect_smob (SCM smob, SCM *prot_cons)
25 SCM s = scm_cdr (smob_protection_list);
26 while (scm_is_pair (s) && scm_car (s) == SCM_UNDEFINED)
31 SCM prot = scm_cons (smob, s);
32 scm_set_cdr_x (smob_protection_list,
38 unprotect_smob (SCM *prot_cons)
40 SCM next = scm_cdr (*prot_cons);
44 scm_set_car_x (*prot_cons, SCM_UNDEFINED);
48 scm_set_car_x (*prot_cons, SCM_UNDEFINED);
49 while (scm_is_pair (next)
50 && scm_car (next) == SCM_UNDEFINED)
53 next = scm_cdr (next);
56 scm_set_cdr_x (*prot_cons, next);