]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/smobs.cc
* lily/smobs.cc (protect_smob): switch off fancy smob protection
[lilypond.git] / lily / smobs.cc
index a6fdc76b9e754ee306802d4d4c213f91960e0e31..9629ed45ee610702f2d3e4b1024b56be9e3ac693 100644 (file)
 /*
   The CDR contains the actual protected list.
  */
-static SCM smob_protection_list;
+static SCM smob_protection_list = SCM_EOL;
 
 void
 init_smob_protection ()
 {
-  smob_protection_list = scm_cons (SCM_UNDEFINED, SCM_EOL);
-  scm_permanent_object (smob_protection_list);
+  smob_protection_list = scm_cons (SCM_BOOL_F, SCM_EOL);
+  scm_gc_protect_object (smob_protection_list);
 }
 ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection);
 
 LY_DEFINE(ly_smob_protects, "ly:smob-protects",
-         0,0,0, (),
+         0, 0, 0, (),
          "Return lily's internal smob protection list")
 {
-  return scm_cdr (smob_protection_list);
+  return scm_is_pair (smob_protection_list)
+    ? scm_cdr (smob_protection_list)
+    : SCM_EOL;
 }
 
-         
-         
-
 void
 protect_smob (SCM smob, SCM *prot_cons)
 {
+#if 0
   SCM s = scm_cdr (smob_protection_list);
-  while (scm_is_pair (s) && scm_car (s) == SCM_UNDEFINED)
-    s = scm_cdr (s);
-
+  while (scm_is_pair (s) && scm_car (s) == SCM_BOOL_F)
+    {
+      s = scm_cdr (s);
+    }
   SCM prot = scm_cons (smob, s);
   scm_set_cdr_x (smob_protection_list,
                 prot);
   *prot_cons = prot;
+#else
+  scm_gc_protect_object (smob);
+#endif
 }
 
 void
-unprotect_smob (SCM *prot_cons)
+unprotect_smob (SCM smob, SCM *prot_cons)
 {
+#if 1
+  scm_gc_unprotect_object (smob);
+#else
   SCM next = scm_cdr (*prot_cons);
 
   if (next == SCM_EOL)
-    scm_set_car_x (*prot_cons, SCM_UNDEFINED);
+    scm_set_car_x (*prot_cons, SCM_BOOL_F);
   else
     {
-      scm_set_car_x (*prot_cons, SCM_UNDEFINED);
+      scm_set_car_x (*prot_cons, SCM_BOOL_F);
       while (scm_is_pair (next)
-            && scm_car (next) == SCM_UNDEFINED)
+            && scm_car (next) == SCM_BOOL_F)
 
        next = scm_cdr (next);
 
@@ -63,4 +70,5 @@ unprotect_smob (SCM *prot_cons)
     }
 
   *prot_cons = SCM_EOL;
+#endif
 }