menu_new(3X)
β¨ menu_new β bestie edition β¨
okay so we're in menu_new(3X), the Library Calls girlies, and today's topic is literally just making and unmaking menus. creation and destruction. the full circle of life π
πΈ NAME πΈ
new_menu, free_menu β spin up a menu, and then (gently) let it go π¦
β¨ SYNOPSIS β¨
#include <menu.h>
MENU *new_menu(ITEM **items);
int free_menu(MENU *menu);
like⦠two functions. that's it. we're so back.
π DESCRIPTION π
okay so new_menu does exactly what it says on the tin: it creates a brand-new menu, and it hooks that menu up to an item pointer array you hand it. and bestie, hear me β that array must be NULL-terminated. not optional. not "ehh probably fine". NULL-terminated. periodt.
and then free_menu? she's the cleanup crew π§Ή she disconnects menu from its item array and frees up the storage that was allocated for the menu. no loose ends, no memory leaks, we love a responsible queen.
π«Ά RETURN VALUE π«Ά
new_menu returns NULL on error (not me getting nothing back π) and it sets errno based on what went wrong:
E_NOT_CONNECTEDβ there are literally no items connected to the menu. she's empty. nothing to work with.E_SYSTEM_ERRORβ a system error happened, like, say, amallocfailure. tragic.
free_menu returns one of these:
E_OKβ the routine succeeded. we ate. πE_SYSTEM_ERRORβ a system error occurred (go peek aterrno(3)for the deets).E_BAD_ARGUMENTβ the routine caught an argument that was incorrect or out of range. π©E_POSTEDβ the menu has already been posted. she's out there. you can't do this rn.
π PORTABILITY π
these routines are out here emulating the System V menu library. iconic behavior, honestly. but heads up: they were not supported on Version 7 or BSD versions. so if you're on those, it's givingβ¦ unsupported. π
π AUTHORS π
Juergen Pfeifer. and the manual pages + adaptation for new curses were done by Eric S. Raymond. credit where credit is due, we respect the OGs π
π SEE ALSO π
curses(3X)menu(3X)
and that's the whole vibe β¨ this was menu_new(3X) from ncurses 6.6, dated 2024-12-28 β go forth, make menus, free them responsibly, and don't leak memory bestie, i'm begging π«Άπ
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 1998-2010,2015 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms