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.
* 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>
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
{
ptrdiff_t total_bytes;
+ cleanup_vector (vector);
nbytes = vector_nbytes (vector);
total_bytes = nbytes;
next = ADVANCE (vector, nbytes);
{
if (VECTOR_MARKED_P (next))
break;
+ cleanup_vector (next);
nbytes = vector_nbytes (next);
total_bytes += nbytes;
next = ADVANCE (next, nbytes);
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).