summaryrefslogtreecommitdiff
path: root/src/font.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2014-07-03 16:20:00 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2014-07-03 16:20:00 +0400
commit60ab579771527dcc29547119f2c1b7099eda4d55 (patch)
tree8804ef001fbd3b73845b9f5dc690dd188054a6f6 /src/font.c
parent95268e987c484b98aac3de54cf91d65db16f4c22 (diff)
downloademacs-60ab579771527dcc29547119f2c1b7099eda4d55.tar.gz
Use convenient alists to manage per-frame font driver-specific data.
* frame.h (struct frame): Rename font_data_list to... [HAVE_XFT || HAVE_FREETYPE]: ... font_data, which is a Lisp_Object now. * font.h (struct font_data_list): Remove; no longer need a special data type. (font_put_frame_data, font_get_frame_data) [HAVE_XFT || HAVE_FREETYPE]: Adjust prototypes. * font.c (font_put_frame_data, font_get_frame_data) [HAVE_XFT || HAVE_FREETYPE]: Prefer alist functions to ad-hoc list management. * xftfont.c (xftfont_get_xft_draw, xftfont_end_for_frame): Related users changed. * ftxfont.c (ftxfont_get_gcs, ftxfont_end_for_frame): Likewise. Prefer convenient xmalloc and xfree.
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c55
1 files changed, 18 insertions, 37 deletions
diff --git a/src/font.c b/src/font.c
index 251d43ba8b2..7b9edcd3fb8 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3539,53 +3539,34 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
return active_drivers;
}
-int
-font_put_frame_data (struct frame *f, struct font_driver *driver, void *data)
-{
- struct font_data_list *list, *prev;
+#if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
- for (prev = NULL, list = f->font_data_list; list;
- prev = list, list = list->next)
- if (list->driver == driver)
- break;
- if (! data)
- {
- if (list)
- {
- if (prev)
- prev->next = list->next;
- else
- f->font_data_list = list->next;
- xfree (list);
- }
- return 0;
- }
+void
+font_put_frame_data (struct frame *f, Lisp_Object driver, void *data)
+{
+ Lisp_Object val = assq_no_quit (driver, f->font_data);
- if (! list)
+ if (!data)
+ f->font_data = Fdelq (val, f->font_data);
+ else
{
- list = xmalloc (sizeof *list);
- list->driver = driver;
- list->next = f->font_data_list;
- f->font_data_list = list;
+ if (NILP (val))
+ f->font_data = Fcons (Fcons (driver, make_save_ptr (data)),
+ f->font_data);
+ else
+ XSETCDR (val, make_save_ptr (data));
}
- list->data = data;
- return 0;
}
-
void *
-font_get_frame_data (struct frame *f, struct font_driver *driver)
+font_get_frame_data (struct frame *f, Lisp_Object driver)
{
- struct font_data_list *list;
-
- for (list = f->font_data_list; list; list = list->next)
- if (list->driver == driver)
- break;
- if (! list)
- return NULL;
- return list->data;
+ Lisp_Object val = assq_no_quit (driver, f->font_data);
+
+ return NILP (val) ? NULL : XSAVE_POINTER (XCDR (val), 0);
}
+#endif /* HAVE_XFT || HAVE_FREETYPE */
/* Sets attributes on a font. Any properties that appear in ALIST and
BOOLEAN_PROPERTIES or NON_BOOLEAN_PROPERTIES are set on the font.