aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-06-14 15:59:08 -0700
committerPaul Eggert2018-06-14 17:13:38 -0700
commit3f0a8a2e14669cf4a1f56e97f8b1299fced79796 (patch)
treedd5b4d0154a5be7ee9a04b3fcfdaa6689935b56a /src
parent12fd59bba0b04fb6727f4fa54e3305a65fae1d44 (diff)
downloademacs-3f0a8a2e14669cf4a1f56e97f8b1299fced79796.tar.gz
emacs-3f0a8a2e14669cf4a1f56e97f8b1299fced79796.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/term.c20
-rw-r--r--src/xmenu.c16
-rw-r--r--src/xterm.c6
3 files changed, 27 insertions, 15 deletions
diff --git a/src/term.c b/src/term.c
index bcd7dd82d6f..85bfa84d937 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)
3408 Qnil, menu_object, make_number (item)); 3408 Qnil, menu_object, make_number (item));
3409} 3409}
3410 3410
3411struct tty_pop_down_menu
3412{
3413 tty_menu *menu;
3414 struct buffer *buffer;
3415};
3416
3411static void 3417static void
3412tty_pop_down_menu (Lisp_Object arg) 3418tty_pop_down_menu (void *arg)
3413{ 3419{
3414 tty_menu *menu = XSAVE_POINTER (arg, 0); 3420 struct tty_pop_down_menu *data = arg;
3415 struct buffer *orig_buffer = XSAVE_POINTER (arg, 1);
3416 3421
3417 block_input (); 3422 block_input ();
3418 tty_menu_destroy (menu); 3423 tty_menu_destroy (data->menu);
3419 set_buffer_internal (orig_buffer); 3424 set_buffer_internal (data->buffer);
3420 unblock_input (); 3425 unblock_input ();
3421} 3426}
3422 3427
@@ -3697,8 +3702,9 @@ tty_menu_show (struct frame *f, int x, int y, int menuflags,
3697 3702
3698 /* We save and restore the current buffer because tty_menu_activate 3703 /* We save and restore the current buffer because tty_menu_activate
3699 triggers redisplay, which switches buffers at will. */ 3704 triggers redisplay, which switches buffers at will. */
3700 record_unwind_protect (tty_pop_down_menu, 3705 record_unwind_protect_ptr (tty_pop_down_menu,
3701 make_save_ptr_ptr (menu, current_buffer)); 3706 &((struct tty_pop_down_menu)
3707 {menu, current_buffer}));
3702 3708
3703 specbind (Qoverriding_terminal_local_map, 3709 specbind (Qoverriding_terminal_local_map,
3704 Fsymbol_value (Qtty_menu_navigation_map)); 3710 Fsymbol_value (Qtty_menu_navigation_map));
diff --git a/src/xmenu.c b/src/xmenu.c
index a5865a6ec27..2fbf9e8bf68 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -2033,11 +2033,18 @@ menu_help_callback (char const *help_string, int pane, int item)
2033 Qnil, menu_object, make_number (item)); 2033 Qnil, menu_object, make_number (item));
2034} 2034}
2035 2035
2036struct pop_down_menu
2037{
2038 struct frame *frame;
2039 XMenu *menu;
2040};
2041
2036static void 2042static void
2037pop_down_menu (Lisp_Object arg) 2043pop_down_menu (void *arg)
2038{ 2044{
2039 struct frame *f = XSAVE_POINTER (arg, 0); 2045 union pop_down_menu *data = arg;
2040 XMenu *menu = XSAVE_POINTER (arg, 1); 2046 struct frame *f = data->frame;
2047 XMenu *menu = data->menu;
2041 2048
2042 block_input (); 2049 block_input ();
2043#ifndef MSDOS 2050#ifndef MSDOS
@@ -2283,7 +2290,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
2283 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 2290 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
2284#endif 2291#endif
2285 2292
2286 record_unwind_protect (pop_down_menu, make_save_ptr_ptr (f, menu)); 2293 record_unwind_protect_pointer (pop_down_menu,
2294 &(struct pop_down_menu) {f, menu});
2287 2295
2288 /* Help display under X won't work because XMenuActivate contains 2296 /* Help display under X won't work because XMenuActivate contains
2289 a loop that doesn't give Emacs a chance to process it. */ 2297 a loop that doesn't give Emacs a chance to process it. */
diff --git a/src/xterm.c b/src/xterm.c
index 00ca18c2a96..48ce7918897 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -544,10 +544,8 @@ x_cr_accumulate_data (void *closure, const unsigned char *data,
544} 544}
545 545
546static void 546static void
547x_cr_destroy (Lisp_Object arg) 547x_cr_destroy (void *cr);
548{ 548{
549 cairo_t *cr = xmint_pointer (arg);
550
551 block_input (); 549 block_input ();
552 cairo_destroy (cr); 550 cairo_destroy (cr);
553 unblock_input (); 551 unblock_input ();
@@ -606,7 +604,7 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type)
606 604
607 cr = cairo_create (surface); 605 cr = cairo_create (surface);
608 cairo_surface_destroy (surface); 606 cairo_surface_destroy (surface);
609 record_unwind_protect (x_cr_destroy, make_mint_ptr (cr)); 607 record_unwind_protect_pointer (x_cr_destroy, cr);
610 608
611 while (1) 609 while (1)
612 { 610 {