mitem_new(3X)
π mitem_new β the ncurses manual, section 3X π
okay bestie, so this is mitem_new(3X) from the ncurses library calls, and it's literally all about making and unmaking menu items β¨
πΈ NAME πΈ
new_item, free_item β create and destroy menu items. it's giving birth and death but for menu items, no cap π
π¦ SYNOPSIS π¦
#include <menu.h>
ITEM *new_item(const char *name, const char *description);
int free_item(ITEM *item);
β¨ DESCRIPTION β¨
so the function new_item allocates a new item and initializes it from the name and description pointers. and bestie, please notice β like actually notice β that the item stores only the pointers to the name and description. those pointers have to stay valid for the whole entire lifetime of the item π
so be super careful with names or descriptions that are allocated on the stack of some routine, because that stack memory is gonna dip on you and the item will be left holding a pointer to absolutely nothing π main character energy only in memory that survives, fr fr.
the function free_item de-allocates an item. and again, heads up: it is the responsibility of the application to release the memory for the name or the description of the item. free_item does not do that for you. it's giving "I handled the item, you handle the strings" π
π RETURN VALUE π
the function new_item returns NULL on error. it sets errno according to the function's failure:
E_BAD_ARGUMENTβ routine detected an incorrect or out-of-range argument. it's giving "that's not it, bestie" πE_SYSTEM_ERRORβ system error occurred, e.g.,mallocfailure. π
the function free_item returns one of the following:
E_OKβ the routine succeeded. slay β¨E_BAD_ARGUMENTβ routine detected an incorrect or out-of-range argument.E_CONNECTEDβ item is connected to a menu. not me trying to free something that's still in a relationship πE_SYSTEM_ERRORβ system error occurred (seeerrno(3)).
π PORTABILITY π
these routines emulate the System V menu library. they were not supported on Version 7 or BSD versions. so if you're on some ancient vibe, they're simply not there π«Ά
π AUTHORS π
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. iconic work honestly β
π§ SEE ALSO π§
curses(3X)menu(3X)
and that's the whole page, bestie π this one's from ncurses 6.6, dated 2024-12-28 β go forth and manage your item memory responsibly, because nobody's coming to clean up your strings for you ππ
π¦ 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