]> code.delx.au - gnu-emacs/commitdiff
Perform font-specific cleanup when font object is swept by GC. See
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 25 Oct 2013 07:28:16 +0000 (11:28 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 25 Oct 2013 07:28:16 +0000 (11:28 +0400)
http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00740.html.
* alloc.c (cleanup_vector): New function.
(sweep_vector): Call it for each reclaimed vector object.
* font.h (struct font): Adjust comment.

src/ChangeLog
src/alloc.c
src/font.h

index cd31196a15a5c5600416a7190afd404a96eb0321..6111e83e801f3c043e6c02e033a377faa0a5e3e7 100644 (file)
@@ -9,9 +9,15 @@
        * nsfont.m (nsfont_close):
        * w32font.c (w32font_close):
        * xfont.c (xfont_close):
-       * xftfont.c (xftfont_close): Adjust driver-specific close
-       functions, tweak comments and make functions safe if called
-       more than once for the same font object.
+       * xftfont.c (xftfont_close): Adjust driver-specific close functions,
+       tweak comments and make functions safe if called more than once for
+       the same font object.
+
+       Perform font-specific cleanup when font object is swept by GC.  See
+       http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00740.html.
+       * alloc.c (cleanup_vector): New function.
+       (sweep_vector): Call it for each reclaimed vector object.
+       * font.h (struct font): Adjust comment.
 
 2013-10-24  Glenn Morris  <rgm@gnu.org>
 
index a65dbb48b93fc55ddc6a9a611525698e99d2adc2..f57e22d9cc0382d1e681b6ce7857b985ee8071fe 100644 (file)
@@ -2837,6 +2837,19 @@ vector_nbytes (struct Lisp_Vector *v)
   return vroundup (size);
 }
 
+/* Release extra resources still in use by VECTOR, which may be any
+   vector-like object.  For now, this is used just to free data in
+   font objects.  */
+
+static void
+cleanup_vector (struct Lisp_Vector *vector)
+{
+  if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT)
+      && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
+         == FONT_OBJECT_MAX))
+    ((struct font *) vector)->driver->close ((struct font *) vector);
+}
+
 /* Reclaim space used by unmarked vectors.  */
 
 static void
@@ -2871,6 +2884,7 @@ sweep_vectors (void)
            {
              ptrdiff_t total_bytes;
 
+             cleanup_vector (vector);
              nbytes = vector_nbytes (vector);
              total_bytes = nbytes;
              next = ADVANCE (vector, nbytes);
@@ -2882,6 +2896,7 @@ sweep_vectors (void)
                {
                  if (VECTOR_MARKED_P (next))
                    break;
+                 cleanup_vector (next);
                  nbytes = vector_nbytes (next);
                  total_bytes += nbytes;
                  next = ADVANCE (next, nbytes);
index 9285330ce545559a3ac5cbc131caf20173921a70..2db8d35af486ae83a1c47e93a4ea59755cdf722e 100644 (file)
@@ -545,7 +545,7 @@ struct font_driver
   Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity,
                        int pixel_size);
 
-  /* Close FONT.  */
+  /* Close FONT.  NOTE: this can be called by GC.  */
   void (*close) (struct font *font);
 
   /* Optional (if FACE->extra is not used).