mirror of
https://github.com/libretro/RetroArch
synced 2025-03-22 07:21:15 +00:00
Cleanups
This commit is contained in:
parent
3aca3bceb9
commit
0bcbf5d972
16
cheats.c
16
cheats.c
@ -32,10 +32,10 @@
|
||||
|
||||
void cheat_manager_apply_cheats(cheat_manager_t *handle)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned idx = 0;
|
||||
unsigned i, idx = 0;
|
||||
|
||||
pretro_cheat_reset();
|
||||
|
||||
for (i = 0; i < handle->size; i++)
|
||||
{
|
||||
if (handle->cheats[i].state)
|
||||
@ -64,10 +64,7 @@ cheat_manager_t *cheat_manager_load(const char *path)
|
||||
|
||||
for (i = 0; i < cheats; i++)
|
||||
{
|
||||
char key[64];
|
||||
char desc_key[256];
|
||||
char code_key[256];
|
||||
char enable_key[256];
|
||||
char key[64], desc_key[256], code_key[256], enable_key[256];
|
||||
char *tmp = NULL;
|
||||
bool tmp_bool = false;
|
||||
|
||||
@ -94,8 +91,9 @@ cheat_manager_t *cheat_manager_load(const char *path)
|
||||
cheat_manager_t *cheat_manager_new(unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
cheat_manager_t *handle = NULL;
|
||||
handle = (cheat_manager_t*)calloc(1, sizeof(struct cheat_manager));
|
||||
cheat_manager_t *handle = (cheat_manager_t*)
|
||||
calloc(1, sizeof(struct cheat_manager));
|
||||
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
@ -176,6 +174,7 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
|
||||
{
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
char msg[256];
|
||||
|
||||
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
|
||||
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
|
||||
(handle->cheats[handle_idx].desc) ?
|
||||
@ -200,6 +199,7 @@ void cheat_manager_index_next(cheat_manager_t *handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
handle->ptr = (handle->ptr + 1) % handle->size;
|
||||
cheat_manager_update(handle, handle->ptr);
|
||||
}
|
||||
|
26
content.c
26
content.c
@ -178,8 +178,14 @@ static ssize_t read_content_file(const char *path, void **buf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Attempt to save valuable RAM data somewhere. */
|
||||
|
||||
/**
|
||||
* dump_to_file_desperate:
|
||||
* @data : pointer to data buffer.
|
||||
* @size : size of @data.
|
||||
* @type : type of file to be saved.
|
||||
*
|
||||
* Attempt to save valuable RAM data somewhere.
|
||||
**/
|
||||
static void dump_to_file_desperate(const void *data,
|
||||
size_t size, unsigned type)
|
||||
{
|
||||
@ -353,7 +359,7 @@ bool load_state(const char *path)
|
||||
void load_ram_file(const char *path, int type)
|
||||
{
|
||||
ssize_t rc;
|
||||
void *buf = NULL;
|
||||
void *buf = NULL;
|
||||
size_t size = pretro_get_memory_size(type);
|
||||
void *data = pretro_get_memory_data(type);
|
||||
|
||||
@ -390,7 +396,7 @@ void load_ram_file(const char *path, int type)
|
||||
void save_ram_file(const char *path, int type)
|
||||
{
|
||||
size_t size = pretro_get_memory_size(type);
|
||||
void *data = pretro_get_memory_data(type);
|
||||
void *data = pretro_get_memory_data(type);
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
@ -435,7 +441,7 @@ static bool load_content(const struct retro_subsystem_info *special,
|
||||
for (i = 0; i < content->size; i++)
|
||||
{
|
||||
const char *path = content->elems[i].data;
|
||||
int attr = content->elems[i].attr.i;
|
||||
int attr = content->elems[i].attr.i;
|
||||
|
||||
bool need_fullpath = attr & 2;
|
||||
bool require_content = attr & 4;
|
||||
@ -629,19 +635,21 @@ bool init_content_file(void)
|
||||
/* Try to extract all content we're going to load if appropriate. */
|
||||
for (i = 0; i < content->size; i++)
|
||||
{
|
||||
const char *ext = NULL;
|
||||
const char *valid_ext = NULL;
|
||||
|
||||
/* Block extract check. */
|
||||
if (content->elems[i].attr.i & 1)
|
||||
continue;
|
||||
|
||||
const char *ext = path_get_extension(content->elems[i].data);
|
||||
|
||||
const char *valid_ext = special ?
|
||||
special->roms[i].valid_extensions :
|
||||
ext = path_get_extension(content->elems[i].data);
|
||||
valid_ext = special ? special->roms[i].valid_extensions :
|
||||
g_extern.system.info.valid_extensions;
|
||||
|
||||
if (ext && !strcasecmp(ext, "zip"))
|
||||
{
|
||||
char temporary_content[PATH_MAX_LENGTH];
|
||||
|
||||
strlcpy(temporary_content, content->elems[i].data,
|
||||
sizeof(temporary_content));
|
||||
|
||||
|
23
core_info.c
23
core_info.c
@ -31,6 +31,7 @@ static void core_info_list_resolve_all_extensions(
|
||||
core_info_list_t *core_info_list)
|
||||
{
|
||||
size_t i, all_ext_len = 0;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
@ -62,6 +63,7 @@ static void core_info_list_resolve_all_firmware(
|
||||
{
|
||||
size_t i;
|
||||
unsigned c;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
@ -104,6 +106,7 @@ core_info_list_t *core_info_list_new(const char *modules_path)
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
struct string_list *contents = (struct string_list*)
|
||||
dir_list_new(modules_path, EXT_EXECUTABLES, false);
|
||||
|
||||
if (!contents)
|
||||
return NULL;
|
||||
|
||||
@ -216,6 +219,7 @@ error:
|
||||
void core_info_list_free(core_info_list_t *core_info_list)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
@ -223,6 +227,9 @@ void core_info_list_free(core_info_list_t *core_info_list)
|
||||
{
|
||||
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
||||
|
||||
if (!info)
|
||||
continue;
|
||||
|
||||
free(info->path);
|
||||
free(info->systemname);
|
||||
free(info->system_manufacturer);
|
||||
@ -264,6 +271,7 @@ size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
||||
num = 0;
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
num += !!core_info_list->list[i].data;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
@ -271,6 +279,7 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list,
|
||||
const char *path, char *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!core_info_list)
|
||||
return false;
|
||||
|
||||
@ -385,13 +394,17 @@ static int core_info_qsort_cmp(const void *a_, const void *b_)
|
||||
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||
const char *path, const core_info_t **infos, size_t *num_infos)
|
||||
{
|
||||
struct string_list *list = NULL;
|
||||
size_t supported = 0, i;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
(void)list;
|
||||
|
||||
core_info_tmp_path = path;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
struct string_list *list = NULL;
|
||||
if (!strcasecmp(path_get_extension(path), "zip"))
|
||||
list = zlib_get_file_list(path);
|
||||
core_info_tmp_list = list;
|
||||
@ -402,11 +415,13 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||
qsort(core_info_list->list, core_info_list->count,
|
||||
sizeof(core_info_t), core_info_qsort_cmp);
|
||||
|
||||
size_t supported, i;
|
||||
supported = 0;
|
||||
for (i = 0; i < core_info_list->count; i++, supported++)
|
||||
{
|
||||
const core_info_t *core = &core_info_list->list[i];
|
||||
|
||||
if (!core)
|
||||
continue;
|
||||
|
||||
if (!core_info_does_support_file(core, path)
|
||||
#ifdef HAVE_ZLIB
|
||||
&& !core_info_does_support_any_file(core, list)
|
||||
@ -432,7 +447,7 @@ static core_info_t *find_core_info(core_info_list_t *list,
|
||||
for (i = 0; i < list->count; i++)
|
||||
{
|
||||
core_info_t *info = (core_info_t*)&list->list[i];
|
||||
if (info->path && !strcmp(info->path, core))
|
||||
if (info && info->path && !strcmp(info->path, core))
|
||||
return info;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user