curses: change from malloc() to nethack's alloc()

There was no provision for malloc() potentially returning Null and it
wasn't integrated with nethack's MONITOR_HEAP.  'heaputil' shows that
the curses interface is leaking like a sieve.  If some things are
actually being allocated separately and then freed from within curses,
those need to be thoroughly documented and maybe switched back to
malloc().
This commit is contained in:
PatR
2019-02-07 16:48:37 -08:00
parent b1de94f922
commit 19d737951e
5 changed files with 36 additions and 22 deletions
+4 -3
View File
@@ -478,7 +478,7 @@ curses_create_nhmenu(winid wid)
return;
}
new_menu = malloc(sizeof (nhmenu));
new_menu = (nhmenu *) alloc((signed) sizeof (nhmenu));
new_menu->wid = wid;
new_menu->prompt = NULL;
new_menu->entries = NULL;
@@ -524,7 +524,7 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
new_str = curses_copy_of(str);
curses_rtrim((char *) new_str);
new_item = malloc(sizeof (nhmenu_item));
new_item = (nhmenu_item *) alloc((unsigned) sizeof (nhmenu_item));
new_item->wid = wid;
new_item->glyph = glyph;
new_item->identifier = *identifier;
@@ -630,7 +630,8 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
curses_destroy_win(win);
if (num_chosen > 0) {
selected = (MENU_ITEM_P *) malloc(num_chosen * sizeof (MENU_ITEM_P));
selected = (MENU_ITEM_P *) alloc((unsigned)
(num_chosen * sizeof (MENU_ITEM_P)));
count = 0;
menu_item_ptr = current_menu->entries;