Previous 15994 Revisions Next

r2966 Saturday 19th July, 2008 at 14:31:31 UTC by Nathan Woods
Now using uimenu's memory pool in the file manager
[src/mess]filemngr.c

src/mess/filemngr.c
r2965r2966
3939typedef struct _file_manager_menu_state file_manager_menu_state;
4040struct _file_manager_menu_state
4141{
42   object_pool *pool;
4342   const device_config *selected_device;
4443   astring *current_directory;
4544   astring *current_file;
r2965r2966
7170***************************************************************************/
7271
7372/*-------------------------------------------------
74    memory_error - report a memory error
75-------------------------------------------------*/
76
77static void memory_error(const char *message)
78{
79   fatalerror("%s", message);
80}
81
82
83
84/*-------------------------------------------------
8573    code_to_ascii - converts an input_code to its
8674   ASCII equivalent
8775-------------------------------------------------*/
r2965r2966
398386   of type osd_directory_entry
399387-------------------------------------------------*/
400388
401static osd_directory_entry *alloc_directory_entry(object_pool *pool, const char *name, osd_dir_entry_type type, UINT64 size)
389static osd_directory_entry *alloc_directory_entry(ui_menu *menu, const char *name, osd_dir_entry_type type, UINT64 size)
402390{
403391   char *name_dupe = NULL;
404392   osd_directory_entry *new_entry;
r2965r2966
406394   
407395   /* allocate the new entry */
408396   name_length = (name != NULL) ? strlen(name) + 1 : 0;
409   new_entry = pool_malloc(pool, sizeof(*new_entry) + name_length);
397   new_entry = ui_menu_pool_alloc(menu, sizeof(*new_entry) + name_length);
410398
411399   /* copy the name, if specified */
412400   if (name != NULL)
r2965r2966
452440
453441   if (dirent_size != ~0)
454442   {
455      new_dirent = alloc_directory_entry(menustate->manager_menustate->pool, dirent_name, dirent_type, dirent_size);
443      new_dirent = alloc_directory_entry(menu, dirent_name, dirent_type, dirent_size);
456444
457445      /* silly hack */
458446      if (text == dirent_name)
r2965r2966
764752      astring_free(menustate->current_file);
765753      menustate->current_file = NULL;
766754   }
767   if (menustate->pool != NULL)
768   {
769      pool_free(menustate->pool);
770      menustate->pool = NULL;
771   }
772755
773756   /* if the menu isn't built, populate now */
774757   if (!ui_menu_populated(menu))
r2965r2966
789772         menustate->current_file = astring_cpyc(astring_alloc(),
790773            image_exists(menustate->selected_device) ? image_basename(menustate->selected_device) : "");
791774
792         /* create a memory pool */
793         menustate->pool = pool_alloc(memory_error);
794
795775         /* push the menu */
796776         child_menu = ui_menu_alloc(machine, menu_file_selector, NULL);
797777         child_menustate = ui_menu_alloc_state(child_menu, sizeof(*child_menustate));

Previous 15994 Revisions Next


© 1998-2018 The MESS Team