summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2013-10-25 11:28:16 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2013-10-25 11:28:16 +0400
commit86bd985ec0060b83fe272e3fcc1d35f19a966ad1 (patch)
tree763c8e570e1c42a30ce846a133217e07b6217788 /src/alloc.c
parent78e0b35c45892995da596c65759fdece3e67129d (diff)
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.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c15
1 files changed, 15 insertions, 0 deletions
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);