mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Cleanups
This commit is contained in:
parent
7dfbfef995
commit
88c04be7a4
1 changed files with 32 additions and 26 deletions
|
@ -508,24 +508,15 @@ static bool apply_patch_content(uint8_t **buf,
|
||||||
ssize_t *size, const char *patch_desc, const char *patch_path,
|
ssize_t *size, const char *patch_desc, const char *patch_path,
|
||||||
patch_func_t func, void *patch_data, ssize_t patch_size)
|
patch_func_t func, void *patch_data, ssize_t patch_size)
|
||||||
{
|
{
|
||||||
size_t target_size;
|
|
||||||
enum patch_error err = PATCH_UNKNOWN;
|
enum patch_error err = PATCH_UNKNOWN;
|
||||||
uint8_t *patched_content = NULL;
|
|
||||||
ssize_t ret_size = *size;
|
ssize_t ret_size = *size;
|
||||||
uint8_t *ret_buf = *buf;
|
uint8_t *ret_buf = *buf;
|
||||||
|
size_t target_size = ret_size * 4; /* Just to be sure. */
|
||||||
if (patch_size < 0)
|
uint8_t *patched_content = (uint8_t*)malloc(target_size);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!path_file_exists(patch_path))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RARCH_LOG("Found %s file in \"%s\", attempting to patch ...\n",
|
RARCH_LOG("Found %s file in \"%s\", attempting to patch ...\n",
|
||||||
patch_desc, patch_path);
|
patch_desc, patch_path);
|
||||||
|
|
||||||
target_size = ret_size * 4; /* Just to be sure. */
|
|
||||||
patched_content = (uint8_t*)malloc(target_size);
|
|
||||||
|
|
||||||
if (!patched_content)
|
if (!patched_content)
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s\n",
|
RARCH_ERR("%s\n",
|
||||||
|
@ -563,7 +554,7 @@ static bool try_bps_patch(bool allow_bps, const char *name_bps,
|
||||||
uint8_t **buf, ssize_t *size)
|
uint8_t **buf, ssize_t *size)
|
||||||
{
|
{
|
||||||
if (allow_bps && !string_is_empty(name_bps))
|
if (allow_bps && !string_is_empty(name_bps))
|
||||||
if (path_is_valid(name_bps))
|
if (path_is_valid(name_bps) && path_file_exists(name_bps))
|
||||||
{
|
{
|
||||||
ssize_t patch_size;
|
ssize_t patch_size;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@ -572,9 +563,14 @@ static bool try_bps_patch(bool allow_bps, const char *name_bps,
|
||||||
if (!filestream_read_file(name_bps, &patch_data, &patch_size))
|
if (!filestream_read_file(name_bps, &patch_data, &patch_size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (patch_size >= 0)
|
||||||
|
{
|
||||||
ret = apply_patch_content(
|
ret = apply_patch_content(
|
||||||
buf, size, "BPS", name_bps,
|
buf, size, "BPS", name_bps,
|
||||||
bps_apply_patch, patch_data, patch_size);
|
bps_apply_patch, patch_data, patch_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patch_data)
|
||||||
free(patch_data);
|
free(patch_data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -585,7 +581,7 @@ static bool try_ups_patch(bool allow_ups, const char *name_ups,
|
||||||
uint8_t **buf, ssize_t *size)
|
uint8_t **buf, ssize_t *size)
|
||||||
{
|
{
|
||||||
if (allow_ups && !string_is_empty(name_ups))
|
if (allow_ups && !string_is_empty(name_ups))
|
||||||
if (path_is_valid(name_ups))
|
if (path_is_valid(name_ups) && path_file_exists(name_ups))
|
||||||
{
|
{
|
||||||
ssize_t patch_size;
|
ssize_t patch_size;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@ -594,9 +590,14 @@ static bool try_ups_patch(bool allow_ups, const char *name_ups,
|
||||||
if (!filestream_read_file(name_ups, &patch_data, &patch_size))
|
if (!filestream_read_file(name_ups, &patch_data, &patch_size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (patch_size >= 0)
|
||||||
|
{
|
||||||
ret = apply_patch_content(
|
ret = apply_patch_content(
|
||||||
buf, size, "UPS", name_ups,
|
buf, size, "UPS", name_ups,
|
||||||
ups_apply_patch, patch_data, patch_size);
|
ups_apply_patch, patch_data, patch_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patch_data)
|
||||||
free(patch_data);
|
free(patch_data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +608,7 @@ static bool try_ips_patch(bool allow_ips,
|
||||||
const char *name_ips, uint8_t **buf, ssize_t *size)
|
const char *name_ips, uint8_t **buf, ssize_t *size)
|
||||||
{
|
{
|
||||||
if (allow_ips && !string_is_empty(name_ips))
|
if (allow_ips && !string_is_empty(name_ips))
|
||||||
if (path_is_valid(name_ips))
|
if (path_is_valid(name_ips) && path_file_exists(name_ips))
|
||||||
{
|
{
|
||||||
ssize_t patch_size;
|
ssize_t patch_size;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@ -616,9 +617,14 @@ static bool try_ips_patch(bool allow_ips,
|
||||||
if (!filestream_read_file(name_ips, &patch_data, &patch_size))
|
if (!filestream_read_file(name_ips, &patch_data, &patch_size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (patch_size >= 0)
|
||||||
|
{
|
||||||
ret = apply_patch_content(
|
ret = apply_patch_content(
|
||||||
buf, size, "IPS", name_ips,
|
buf, size, "IPS", name_ips,
|
||||||
ips_apply_patch, patch_data, patch_size);
|
ips_apply_patch, patch_data, patch_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patch_data)
|
||||||
free(patch_data);
|
free(patch_data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue