Skip to content

Commit

Permalink
Create database_info_get_current_element_name
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 29, 2016
1 parent b286703 commit cfe9112
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions database_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,10 @@ enum database_type database_info_get_type(database_info_handle_t *handle)
return DATABASE_TYPE_NONE;
return handle->type;
}

const char *database_info_get_current_element_name(database_info_handle_t *handle)
{
if (!handle || !handle->list)
return NULL;
return handle->list->elems[handle->list_ptr].data;
}
2 changes: 2 additions & 0 deletions database_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ database_info_handle_t *database_info_file_init(const char *path,

void database_info_set_type(database_info_handle_t *handle, enum database_type type);

const char *database_info_get_current_element_name(database_info_handle_t *handle);

enum database_type database_info_get_type(database_info_handle_t *handle);

void database_info_free(database_info_handle_t *handle);
Expand Down
10 changes: 5 additions & 5 deletions tasks/task_database.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ static int database_info_list_iterate_found_match(
settings_t *settings = config_get_ptr();
const char *db_path =
db_state->list->elems[db_state->list_index].data;
const char *entry_path = db ?
db->list->elems[db->list_ptr].data : NULL;
const char *entry_path =
database_info_get_current_element_name(db);
database_info_t *db_info_entry =
&db_state->info->list[db_state->entry_index];

Expand Down Expand Up @@ -495,10 +495,10 @@ static int task_database_iterate(database_state_handle_t *db_state,
{
const char *name = NULL;

if (!db || !db->list)
if (!db)
return -1;

name = db->list->elems[db->list_ptr].data;
name = database_info_get_current_element_name(db);

if (!name)
return 0;
Expand Down Expand Up @@ -572,7 +572,7 @@ static void task_database_handler(retro_task_t *task)
dbinfo->status = DATABASE_STATUS_ITERATE_START;
break;
case DATABASE_STATUS_ITERATE_START:
name = dbinfo->list->elems[dbinfo->list_ptr].data;
name = database_info_get_current_element_name(dbinfo);
task_database_cleanup_state(dbstate);
dbstate->list_index = 0;
dbstate->entry_index = 0;
Expand Down

0 comments on commit cfe9112

Please sign in to comment.