Commits

Michele Bini committed 8f25d23

Helper macros for extra_gc_roots.

Comments (0)

Files changed (2)

 #define MAX_STANDARD_FRINGE_BITMAPS (sizeof (standard_bitmaps)/sizeof (standard_bitmaps[0]))
 
 static struct fringe_bitmap **fringe_bitmaps;
-static Lisp_Object fringe_faces;
-static Lisp_Object fringe_faces_rootcell; // Cons cell linking fringe_faces list to GC roots
+DECLARE_GC_ROOT(fringe_faces);
 static int max_fringe_bitmaps;
 
 #ifndef HAVE_NS
 		for (i = 0; i < max_fringe_bitmaps; i++) {
 		  ASET(new_vector, n, AREF(fringe_faces, n));
 		}
-		XSETCAR(fringe_faces_rootcell, fringe_faces);
+		REFRESH_GC_ROOT(fringe_faces);
 	      }
 
 	      for (i = max_fringe_bitmaps; i < bitmaps; i++)
 void
 init_fringe (void)
 {
-  static int initialized = 0;
   int i;
 
   max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
 
   fringe_bitmaps
     = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
-  fringe_faces = Fmake_vector(make_number(max_fringe_bitmaps), Qnil);
-  if (!initialized) {
-    extra_gc_roots =
-      fringe_faces_rootcell =
-      Fcons(fringe_faces, extra_gc_roots);
-  } else {
-    XSETCAR(fringe_faces_rootcell, fringe_faces);
-  }
+  INSTALL_GC_ROOT(fringe_faces, Fmake_vector(make_number(max_fringe_bitmaps), Qnil));
 
   for (i = 0; i < max_fringe_bitmaps; i++)
     {
       fringe_bitmaps[i] = NULL;
     }
-
-  initialized = 1;
 }
 
 #ifdef HAVE_NTGUI
 };
 
 extern Lisp_Object extra_gc_roots; /* Lisp list holding extra gc roots */
+#define DECLARE_GC_ROOT(var) static Lisp_Object var; static Lisp_Object var##__rootcell;  static Lisp_Object var##__rootcell_init = 0
+#define REFRESH_GC_ROOT(var) XSETCAR(var##__rootcell, var)
+#define INSTALL_GC_ROOT(var, value) do { var = value; if (!var##__rootcell_init) { extra_gc_roots = var##__rootcell = Fcons(var, extra_gc_roots); var##__rootcell_init=1; } else { REFRESH_GC_ROOT(var); } } while (0)
 
 #undef GC_MARK_STACK /* undef for developing incremental GC */