+ struct pmenu *menu = cui->main;
+ struct cui_opt_data *cod;
+
+ /* Was the edit cancelled? */
+ if (!bd) {
+ cui_set_current(cui, &cui->main->scr);
+ talloc_free(cui->boot_editor);
+ cui->boot_editor = NULL;
+ return;
+ }
+
+ /* Is this was a new item, we'll need to update the menu */
+ if (!item) {
+ int insert_pt;
+
+ /* Detach the items array. */
+ set_menu_items(menu->ncm, NULL);
+
+ /* Insert new item at insert_pt. */
+ insert_pt = pmenu_grow(menu, 1);
+ item = pmenu_item_alloc(menu);
+ item->on_edit = cui_item_edit;
+ item->on_execute = cui_boot;
+ item->data = cod = talloc_zero(item, struct cui_opt_data);
+
+ cod->name = talloc_asprintf(cod, "User item %u:", insert_pt);
+ pmenu_item_setup(menu, item, insert_pt,
+ talloc_strdup(item, cod->name));
+
+ /* Re-attach the items array. */
+ set_menu_items(menu->ncm, menu->items);
+ nc_scr_post(&menu->scr);
+ } else {
+ cod = item->data;
+ }