new(3MENU)

πŸ’– new(3MENU) πŸ’–

okay so bestie, welcome to the Library calls section, this is new(3MENU) and we're talking about menus β€” the make-one, break-one kind πŸŽ€


✨ NAME ✨

new_menu, free_menu β€” create and destroy menus 🫢


🌸 SYNOPSIS 🌸

#include <menu.h>

MENU *new_menu(ITEM **items);
int free_menu(MENU *menu);

πŸ’… DESCRIPTION πŸ’…

so new_menu does exactly what it says on the tin, no cap β€” it creates a brand new menu and connects it to a specified item pointer array. and that array MUST be NULL-terminated, bestie, don't forget, the NULL is literally the vibe check at the end of the list πŸ‘‘

and then free_menu? that's the breakup function 😭 it disconnects menu from its item array and frees all the storage that was allocated for the menu. clean exit, no loose ends, we love to see it ✨


πŸ”₯ RETURN VALUE πŸ”₯

new_menu returns NULL on error. not great, not terrible, but it sets errno to tell you why it flopped:

  • E_NOT_CONNECTED β€” no items are connected to the menu. it's giving empty roster πŸ’€
  • E_SYSTEM_ERROR β€” a system error occurred, e.g., malloc failure. the machine said no πŸ™ˆ

and free_menu returns one of these lil guys:

  • E_OK β€” the routine succeeded. ate and left no crumbs πŸ’…
  • E_SYSTEM_ERROR β€” system error occurred (see errno(3)). go check that man page, iykyk πŸ”
  • E_BAD_ARGUMENT β€” the routine detected an incorrect or out-of-range argument. someone handed it nonsense fr fr 😭
  • E_POSTED β€” the menu has already been posted. bestie it's out there, you can't just free it while it's live 🚫

🌈 PORTABILITY 🌈

these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions β€” so if you're on ancient territory, that's a no from them 🧚


πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute icons, we stan ⭐


πŸ¦‹ SEE ALSO πŸ¦‹

  • ncurses(3NCURSES)
  • menu(3MENU)

and that's the whole page, bestie!! this lil manual came to you from ncurses 6.6, dated 2024-12-28 β€” signed, sealed, and slaying πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from