void MenuSystemTerminate(MenuSystem *ms) { MenuDestroySubmenus(ms->root); CFREE(ms->root); CArrayTerminate(&ms->exitTypes); CArrayTerminate(&ms->customDisplayFuncs); memset(ms, 0, sizeof *ms); }
void MenuSystemTerminate(MenuSystem *ms) { MenuDestroySubmenus(ms->root); CFREE(ms->root); CFREE(ms->customDisplayFuncs); CFREE(ms->customDisplayDatas); memset(ms, 0, sizeof *ms); }
void MenuDestroy(MenuSystem *menu) { if (menu == NULL || menu->root == NULL) { return; } MenuDestroySubmenus(menu->root); CFREE(menu->root); CFREE(menu); }
void MenuDestroySubmenus(menu_t *menu) { if (menu == NULL) { return; } CFREE(menu->name); if (MenuTypeHasSubMenus(menu->type)) { for (int i = 0; i < (int)menu->u.normal.subMenus.size; i++) { menu_t *subMenu = CArrayGet(&menu->u.normal.subMenus, i); MenuDestroySubmenus(subMenu); } CArrayTerminate(&menu->u.normal.subMenus); } }
void MenuDestroySubmenus(menu_t *menu) { if (menu == NULL) { return; } if (MenuTypeHasSubMenus(menu->type) && menu->u.normal.subMenus != NULL) { int i; for (i = 0; i < menu->u.normal.numSubMenus; i++) { menu_t *subMenu = &menu->u.normal.subMenus[i]; MenuDestroySubmenus(subMenu); } CFREE(menu->u.normal.subMenus); } }