static void
digest_menu_items (void *first_menu, int start, int menu_items_used,
- int mbar_p)
+ bool is_menu_bar)
{
void **menus, **panes;
- ssize_t menu_len = (menu_items_used + 1 - start) * sizeof *menus;
- ssize_t pane_len = (menu_items_used + 1 - start) * sizeof *panes;
+ ssize_t menu_len;
+ ssize_t pane_len;
+ int i, menu_depth;
+ void *menu, *window, *view;
+ Lisp_Object pane_name, prefix;
+ const char *pane_string;
+ Lisp_Object item_name, enable, descrip, def, selected, help;
- menus = alloca (menu_len);
- panes = alloca (pane_len);
+ USE_SAFE_ALLOCA;
- int i = start, menu_depth = 0;
+ menu_len = (menu_items_used + 1 - start) * sizeof *menus;
+ pane_len = (menu_items_used + 1 - start) * sizeof *panes;
+ menu = first_menu;
+ i = start;
+ menu_depth = 0;
+
+ menus = SAFE_ALLOCA (menu_len);
+ panes = SAFE_ALLOCA (pane_len);
memset (menus, 0, menu_len);
memset (panes, 0, pane_len);
-
- void *menu = first_menu;
-
menus[0] = first_menu;
- void *window = NULL;
- void *view = NULL;
+ window = NULL;
+ view = NULL;
+
if (FRAMEP (Vmenu_updating_frame) &&
FRAME_LIVE_P (XFRAME (Vmenu_updating_frame)) &&
FRAME_HAIKU_P (XFRAME (Vmenu_updating_frame)))
i += 1;
else if (EQ (AREF (menu_items, i), Qt))
{
- Lisp_Object pane_name, prefix;
- const char *pane_string;
-
if (menu_items_n_panes == 1)
{
i += MENU_ITEMS_PANE_LENGTH;
}
else
{
- Lisp_Object item_name, enable, descrip, def, selected, help;
item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
menu = BMenu_new_submenu (menu, SSDATA (item_name), !NILP (enable));
else if (NILP (def) && menu_separator_name_p (SSDATA (item_name)))
BMenu_add_separator (menu);
- else if (!mbar_p)
+ else if (!is_menu_bar)
{
if (!use_system_tooltips || NILP (Fsymbol_value (Qtooltip_mode)))
BMenu_add_item (menu, SSDATA (item_name),
if (view)
BView_draw_unlock (view);
+
+ SAFE_FREE ();
}
static Lisp_Object
haiku_menu_show (struct frame *f, int x, int y, int menuflags,
Lisp_Object title, const char **error_name)
{
- int i = 0, submenu_depth = 0;
- void *view = FRAME_HAIKU_VIEW (f);
- void *menu;
+ int i, submenu_depth, j;
+ void *view, *menu;
+ Lisp_Object *subprefix_stack;
+ Lisp_Object prefix, entry;
- Lisp_Object *subprefix_stack =
- alloca (menu_items_used * sizeof (Lisp_Object));
+ USE_SAFE_ALLOCA;
+
+ view = FRAME_HAIKU_VIEW (f);
+ i = 0;
+ submenu_depth = 0;
+ subprefix_stack
+ = SAFE_ALLOCA (menu_items_used * sizeof (Lisp_Object));
eassert (FRAME_HAIKU_P (f));
if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
{
*error_name = "Empty menu";
+
+ SAFE_FREE ();
return Qnil;
}
if (menu_item_selection)
{
- Lisp_Object prefix, entry;
-
prefix = entry = Qnil;
i = 0;
while (i < menu_items_used)
{
if (menuflags & MENU_KEYMAPS)
{
- int j;
-
entry = list1 (entry);
if (!NILP (prefix))
entry = Fcons (prefix, entry);
block_input ();
BPopUpMenu_delete (menu);
unblock_input ();
+
+ SAFE_FREE ();
return entry;
}
i += MENU_ITEMS_ITEM_LENGTH;
block_input ();
BPopUpMenu_delete (menu);
unblock_input ();
+
+ SAFE_FREE ();
return Qnil;
}