Commit 3f0a8a2e authored by Paul Eggert's avatar Paul Eggert

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.
parent 12fd59bb
......@@ -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));
......
......@@ -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. */
......
......@@ -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)
{
......
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