/* Returns a pointer to the menu if successful, or NULL if there is insufficient memory available to create the menu.  */
struct menu* menu_create(char *title, int timeout, int prompt, void(*item_data_print)(void *), char *(*item_choice)(void *), void *item_choice_data)
/* Returns a pointer to the menu if successful, or NULL if there is insufficient memory available to create the menu.  */
struct menu* menu_create(char *title, int timeout, int prompt, void(*item_data_print)(void *), char *(*item_choice)(void *), void *item_choice_data)
{
	struct menu *m;
	m = malloc(sizeof *m);
	if (!m)
		return NULL;
	m->default_item = NULL;
	m->prompt = prompt;
	m->timeout = timeout;
	m->item_data_print = item_data_print;
	m->item_choice = item_choice;
	m->item_choice_data = item_choice_data;
	m->item_cnt = 0;
	if (title) {
		m->title = strdup(title);
		if (!m->title) {
			free(m);
			return NULL;
		}
	} else
		m->title = NULL;
	INIT_LIST_HEAD(&m->items);
	return m;
}