I'll answer this for future searchers. It turns out that new_menu takes a pointer to an ITEM list and hangs onto it. If the ITEM list is on the stack of a function, it'll get deleted when the function returns, making the ITEM list invalid.
The solution to this problem is to create the ITEM list on the heap, either via new
in C++, or using malloc
(remember to delete
or free
!). Another option is to wrap the MENU in a class and keep the ITEM list as a member variable.
The simplest solution is to just make the MENU (or ITEM list) global.