From 86bd985ec0060b83fe272e3fcc1d35f19a966ad1 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 25 Oct 2013 11:28:16 +0400 Subject: 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. --- src/alloc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/alloc.c') 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); -- cgit v1.2.1