2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
23 The CDR contains the actual protected list.
25 static SCM smob_protection_list = SCM_EOL;
28 init_smob_protection ()
30 smob_protection_list = scm_cons (SCM_BOOL_F, SCM_EOL);
31 scm_gc_protect_object (smob_protection_list);
33 ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection);
35 LY_DEFINE (ly_smob_protects, "ly:smob-protects",
37 "Return LilyPond's internal smob protection list.")
39 return scm_is_pair (smob_protection_list)
40 ? scm_cdr (smob_protection_list)
45 protect_smob (SCM smob, SCM *prot_cons)
48 SCM s = scm_cdr (smob_protection_list);
49 while (scm_is_pair (s) && scm_car (s) == SCM_BOOL_F)
53 SCM prot = scm_cons (smob, s);
54 scm_set_cdr_x (smob_protection_list,
59 scm_gc_protect_object (smob);
64 unprotect_smob (SCM smob, SCM *prot_cons)
68 scm_gc_unprotect_object (smob);
70 SCM next = scm_cdr (*prot_cons);
73 scm_set_car_x (*prot_cons, SCM_BOOL_F);
76 scm_set_car_x (*prot_cons, SCM_BOOL_F);
77 while (scm_is_pair (next)
78 && scm_car (next) == SCM_BOOL_F)
80 next = scm_cdr (next);
82 scm_set_cdr_x (*prot_cons, next);