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 *= 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)
@ -43,10 +44,12 @@ void file_list_push(file_list_t *list,
rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list();
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)
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
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].directory_ptr = directory_ptr;
list->size++;
}
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)
{
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_)
@ -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();
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;
}
@ -184,14 +188,17 @@ bool file_list_search(const file_list_t *list, const char *needle, size_t *index
continue;
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;
ret = true;
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;
ret = true;
}

View file

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