Code reformatting

This commit is contained in:
twinaphex 2014-08-20 17:23:21 +02:00
parent 1d043121e2
commit d1110ff592
2 changed files with 30 additions and 17 deletions

View File

@ -31,7 +31,8 @@ void file_list_push(file_list_t *list,
{ {
list->capacity++; list->capacity++;
list->capacity *= 2; list->capacity *= 2;
list->list = (struct item_file*)realloc(list->list, list->capacity * sizeof(struct item_file)); list->list = (struct item_file*)realloc(list->list,
list->capacity * sizeof(struct item_file));
} }
if (driver.menu_ctx && driver.menu_ctx->list_insert) if (driver.menu_ctx && driver.menu_ctx->list_insert)
@ -43,10 +44,12 @@ void file_list_push(file_list_t *list,
rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list();
if (setting_data) if (setting_data)
list->list[list->size].setting = (rarch_setting_t*)setting_data_find_setting(setting_data, label); list->list[list->size].setting = (rarch_setting_t*)
setting_data_find_setting(setting_data, label);
if (list->list[list->size].setting) if (list->list[list->size].setting)
list->list[list->size].path = strdup(list->list[list->size].setting->short_description); list->list[list->size].path = strdup(
list->list[list->size].setting->short_description);
else else
list->list[list->size].path = strdup(path); list->list[list->size].path = strdup(path);
@ -54,7 +57,6 @@ void file_list_push(file_list_t *list,
list->list[list->size].type = type; list->list[list->size].type = type;
list->list[list->size].directory_ptr = directory_ptr; list->list[list->size].directory_ptr = directory_ptr;
list->size++; list->size++;
} }
size_t file_list_get_size(const file_list_t *list) size_t file_list_get_size(const file_list_t *list)
@ -126,7 +128,8 @@ void file_list_get_alt_at_offset(const file_list_t *list, size_t index,
const char **alt) const char **alt)
{ {
if (alt) if (alt)
*alt = list->list[index].alt ? list->list[index].alt : list->list[index].path; *alt = list->list[index].alt ?
list->list[index].alt : list->list[index].path;
} }
static int file_list_alt_cmp(const void *a_, const void *b_) static int file_list_alt_cmp(const void *a_, const void *b_)
@ -166,7 +169,8 @@ void *file_list_get_last_setting(const file_list_t *list, int index)
rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list();
if (setting_data) if (setting_data)
return (rarch_setting_t*)setting_data_find_setting(setting_data, list->list[index].label); return (rarch_setting_t*)setting_data_find_setting(setting_data,
list->list[index].label);
return NULL; return NULL;
} }
@ -184,14 +188,17 @@ bool file_list_search(const file_list_t *list, const char *needle, size_t *index
continue; continue;
str = (const char *)strcasestr(alt, needle); str = (const char *)strcasestr(alt, needle);
if (str == alt) // Found match with first chars, best possible match. if (str == alt)
{ {
/* Found match with first chars, best possible match. */
*index = i; *index = i;
ret = true; ret = true;
break; break;
} }
else if (str && !ret) // Found mid-string match, but try to find a match with first chars before we settle. else if (str && !ret)
{ {
/* Found mid-string match, but try to find a match with
* first characters before we settle. */
*index = i; *index = i;
ret = true; ret = true;
} }

View File

@ -55,7 +55,8 @@ void content_playlist_get_index(content_playlist_t *playlist,
*core_name = playlist->entries[index].core_name; *core_name = playlist->entries[index].core_name;
} }
static void content_playlist_free_entry(struct content_playlist_entry *entry) static void content_playlist_free_entry(
struct content_playlist_entry *entry)
{ {
if (entry->path) if (entry->path)
free(entry->path); free(entry->path);
@ -82,16 +83,17 @@ void content_playlist_push(content_playlist_t *playlist,
for (i = 0; i < playlist->size; i++) for (i = 0; i < playlist->size; i++)
{ {
bool equal_path = (!path && !playlist->entries[i].path) || bool equal_path = (!path && !playlist->entries[i].path) ||
(path && playlist->entries[i].path && !strcmp(path, playlist->entries[i].path)); (path && playlist->entries[i].path &&
!strcmp(path,playlist->entries[i].path));
// Core name can have changed while still being the same core. /* Core name can have changed while still being the same core.
// Differentiate based on the core path only. * Differentiate based on the core path only. */
if (equal_path && !strcmp(playlist->entries[i].core_path, core_path)) if (equal_path && !strcmp(playlist->entries[i].core_path, core_path))
{ {
if (i == 0) if (i == 0)
return; return;
// Seen it before, bump to top. /* Seen it before, bump to top. */
struct content_playlist_entry tmp = playlist->entries[i]; struct content_playlist_entry tmp = playlist->entries[i];
memmove(playlist->entries + 1, playlist->entries, memmove(playlist->entries + 1, playlist->entries,
i * sizeof(struct content_playlist_entry)); i * sizeof(struct content_playlist_entry));
@ -127,7 +129,8 @@ static void content_playlist_write_file(content_playlist_t *playlist)
if (!file) if (!file)
{ {
RARCH_ERR("Couldn't write to content playlist file: %s.\n", playlist->conf_path); RARCH_ERR("Couldn't write to content playlist file: %s.\n",
playlist->conf_path);
return; return;
} }
@ -177,7 +180,8 @@ size_t content_playlist_size(content_playlist_t *playlist)
return 0; return 0;
} }
static bool content_playlist_read_file(content_playlist_t *playlist, const char *path) static bool content_playlist_read_file(
content_playlist_t *playlist, const char *path)
{ {
char buf[3][PATH_MAX]; char buf[3][PATH_MAX];
unsigned i; unsigned i;
@ -224,14 +228,16 @@ end:
content_playlist_t *content_playlist_init(const char *path, size_t size) content_playlist_t *content_playlist_init(const char *path, size_t size)
{ {
RARCH_LOG("Opening playlist: %s.\n", path); RARCH_LOG("Opening playlist: %s.\n", path);
content_playlist_t *playlist = (content_playlist_t*)calloc(1, sizeof(*playlist)); content_playlist_t *playlist = (content_playlist_t*)
calloc(1, sizeof(*playlist));
if (!playlist) if (!playlist)
{ {
RARCH_ERR("Cannot initialize content playlist.\n"); RARCH_ERR("Cannot initialize content playlist.\n");
return NULL; return NULL;
} }
playlist->entries = (struct content_playlist_entry*)calloc(size, sizeof(*playlist->entries)); playlist->entries = (struct content_playlist_entry*)calloc(size,
sizeof(*playlist->entries));
if (!playlist->entries) if (!playlist->entries)
goto error; goto error;