[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 3f0a8a2 04/10: Use record_unwind_protect_ptr to avo
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 3f0a8a2 04/10: Use record_unwind_protect_ptr to avoid allocation |
Date: |
Thu, 14 Jun 2018 20:15:24 -0400 (EDT) |
branch: master
commit 3f0a8a2e14669cf4a1f56e97f8b1299fced79796
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Use record_unwind_protect_ptr to avoid allocation
* src/term.c (struct tty_pop_down_menu): New type.
(tty_pop_down_menu, tty_menu_show): Use it, along with
record_unwind_protect_ptr, to avoid allocating a Lisp_Misc.
* src/xmenu.c (struct pop_down_menu): New type.
(pop_down_menu, x_menu_show): Use it, likewise.
* src/xterm.c (x_cr_destroy, x_cr_export_frames):
Use record_unwind_protect_pointer to avoid possibly allocating
a Lisp_Misc.
---
src/term.c | 20 +++++++++++++-------
src/xmenu.c | 16 ++++++++++++----
src/xterm.c | 6 ++----
3 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/term.c b/src/term.c
index bcd7dd8..85bfa84 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3408,15 +3408,20 @@ tty_menu_help_callback (char const *help_string, int
pane, int item)
Qnil, menu_object, make_number (item));
}
+struct tty_pop_down_menu
+{
+ tty_menu *menu;
+ struct buffer *buffer;
+};
+
static void
-tty_pop_down_menu (Lisp_Object arg)
+tty_pop_down_menu (void *arg)
{
- tty_menu *menu = XSAVE_POINTER (arg, 0);
- struct buffer *orig_buffer = XSAVE_POINTER (arg, 1);
+ struct tty_pop_down_menu *data = arg;
block_input ();
- tty_menu_destroy (menu);
- set_buffer_internal (orig_buffer);
+ tty_menu_destroy (data->menu);
+ set_buffer_internal (data->buffer);
unblock_input ();
}
@@ -3697,8 +3702,9 @@ tty_menu_show (struct frame *f, int x, int y, int
menuflags,
/* We save and restore the current buffer because tty_menu_activate
triggers redisplay, which switches buffers at will. */
- record_unwind_protect (tty_pop_down_menu,
- make_save_ptr_ptr (menu, current_buffer));
+ record_unwind_protect_ptr (tty_pop_down_menu,
+ &((struct tty_pop_down_menu)
+ {menu, current_buffer}));
specbind (Qoverriding_terminal_local_map,
Fsymbol_value (Qtty_menu_navigation_map));
diff --git a/src/xmenu.c b/src/xmenu.c
index a5865a6..2fbf9e8 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -2033,11 +2033,18 @@ menu_help_callback (char const *help_string, int pane,
int item)
Qnil, menu_object, make_number (item));
}
+struct pop_down_menu
+{
+ struct frame *frame;
+ XMenu *menu;
+};
+
static void
-pop_down_menu (Lisp_Object arg)
+pop_down_menu (void *arg)
{
- struct frame *f = XSAVE_POINTER (arg, 0);
- XMenu *menu = XSAVE_POINTER (arg, 1);
+ union pop_down_menu *data = arg;
+ struct frame *f = data->frame;
+ XMenu *menu = data->menu;
block_input ();
#ifndef MSDOS
@@ -2283,7 +2290,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
#endif
- record_unwind_protect (pop_down_menu, make_save_ptr_ptr (f, menu));
+ record_unwind_protect_pointer (pop_down_menu,
+ &(struct pop_down_menu) {f, menu});
/* Help display under X won't work because XMenuActivate contains
a loop that doesn't give Emacs a chance to process it. */
diff --git a/src/xterm.c b/src/xterm.c
index 00ca18c..48ce791 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -544,10 +544,8 @@ x_cr_accumulate_data (void *closure, const unsigned char
*data,
}
static void
-x_cr_destroy (Lisp_Object arg)
+x_cr_destroy (void *cr);
{
- cairo_t *cr = xmint_pointer (arg);
-
block_input ();
cairo_destroy (cr);
unblock_input ();
@@ -606,7 +604,7 @@ x_cr_export_frames (Lisp_Object frames,
cairo_surface_type_t surface_type)
cr = cairo_create (surface);
cairo_surface_destroy (surface);
- record_unwind_protect (x_cr_destroy, make_mint_ptr (cr));
+ record_unwind_protect_pointer (x_cr_destroy, cr);
while (1)
{
- [Emacs-diffs] master updated (51adab5 -> 4139c98), Paul Eggert, 2018/06/14
- [Emacs-diffs] master 12fd59b 03/10: Avoid Lisp_Misc allocation if C stack suffices, Paul Eggert, 2018/06/14
- [Emacs-diffs] master ef66660 02/10: Simplify init_module_assertions, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 3f0a8a2 04/10: Use record_unwind_protect_ptr to avoid allocation,
Paul Eggert <=
- [Emacs-diffs] master 30d393f 01/10: New mint_ptr representation for C pointers, Paul Eggert, 2018/06/14
- [Emacs-diffs] master d98670e 08/10: Avoid allocating Lisp_Save_Value for arrays, Paul Eggert, 2018/06/14
- [Emacs-diffs] master f8ad6b3 09/10: New type Lisp_Misc_Ptr, Paul Eggert, 2018/06/14
- [Emacs-diffs] master aca938d 07/10: Avoid allocating Lisp_Save_Value for excursions, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 888bf98 05/10: Avoid allocating a Lisp_Save_Value in ftfont.c, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 6c04c84 06/10: Just use cons in macfont_descriptor_entity, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 4139c98 10/10: Remove Lisp_Misc_Save_Value, Paul Eggert, 2018/06/14