Commit 86bd985e authored by Dmitry Antipov's avatar Dmitry Antipov

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.
parent 78e0b35c
......@@ -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>
......
......@@ -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);
......
......@@ -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).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment