summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog12
-rw-r--r--src/alloc.c15
-rw-r--r--src/font.h2
3 files changed, 25 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cd31196a15a..6111e83e801 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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>
diff --git a/src/alloc.c b/src/alloc.c
index a65dbb48b93..f57e22d9cc0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -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);
diff --git a/src/font.h b/src/font.h
index 9285330ce54..2db8d35af48 100644
--- a/src/font.h
+++ b/src/font.h
@@ -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).