aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-10-25 11:28:16 +0400
committerDmitry Antipov2013-10-25 11:28:16 +0400
commit86bd985ec0060b83fe272e3fcc1d35f19a966ad1 (patch)
tree763c8e570e1c42a30ce846a133217e07b6217788 /src
parent78e0b35c45892995da596c65759fdece3e67129d (diff)
downloademacs-86bd985ec0060b83fe272e3fcc1d35f19a966ad1.tar.gz
emacs-86bd985ec0060b83fe272e3fcc1d35f19a966ad1.zip
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')
-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 @@
9 * nsfont.m (nsfont_close): 9 * nsfont.m (nsfont_close):
10 * w32font.c (w32font_close): 10 * w32font.c (w32font_close):
11 * xfont.c (xfont_close): 11 * xfont.c (xfont_close):
12 * xftfont.c (xftfont_close): Adjust driver-specific close 12 * xftfont.c (xftfont_close): Adjust driver-specific close functions,
13 functions, tweak comments and make functions safe if called 13 tweak comments and make functions safe if called more than once for
14 more than once for the same font object. 14 the same font object.
15
16 Perform font-specific cleanup when font object is swept by GC. See
17 http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00740.html.
18 * alloc.c (cleanup_vector): New function.
19 (sweep_vector): Call it for each reclaimed vector object.
20 * font.h (struct font): Adjust comment.
15 21
162013-10-24 Glenn Morris <rgm@gnu.org> 222013-10-24 Glenn Morris <rgm@gnu.org>
17 23
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)
2837 return vroundup (size); 2837 return vroundup (size);
2838} 2838}
2839 2839
2840/* Release extra resources still in use by VECTOR, which may be any
2841 vector-like object. For now, this is used just to free data in
2842 font objects. */
2843
2844static void
2845cleanup_vector (struct Lisp_Vector *vector)
2846{
2847 if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT)
2848 && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
2849 == FONT_OBJECT_MAX))
2850 ((struct font *) vector)->driver->close ((struct font *) vector);
2851}
2852
2840/* Reclaim space used by unmarked vectors. */ 2853/* Reclaim space used by unmarked vectors. */
2841 2854
2842static void 2855static void
@@ -2871,6 +2884,7 @@ sweep_vectors (void)
2871 { 2884 {
2872 ptrdiff_t total_bytes; 2885 ptrdiff_t total_bytes;
2873 2886
2887 cleanup_vector (vector);
2874 nbytes = vector_nbytes (vector); 2888 nbytes = vector_nbytes (vector);
2875 total_bytes = nbytes; 2889 total_bytes = nbytes;
2876 next = ADVANCE (vector, nbytes); 2890 next = ADVANCE (vector, nbytes);
@@ -2882,6 +2896,7 @@ sweep_vectors (void)
2882 { 2896 {
2883 if (VECTOR_MARKED_P (next)) 2897 if (VECTOR_MARKED_P (next))
2884 break; 2898 break;
2899 cleanup_vector (next);
2885 nbytes = vector_nbytes (next); 2900 nbytes = vector_nbytes (next);
2886 total_bytes += nbytes; 2901 total_bytes += nbytes;
2887 next = ADVANCE (next, nbytes); 2902 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
545 Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity, 545 Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity,
546 int pixel_size); 546 int pixel_size);
547 547
548 /* Close FONT. */ 548 /* Close FONT. NOTE: this can be called by GC. */
549 void (*close) (struct font *font); 549 void (*close) (struct font *font);
550 550
551 /* Optional (if FACE->extra is not used). 551 /* Optional (if FACE->extra is not used).