(task_save.c) Simplification in control flow

(snprintf) Try to reduce or simplify snprintf calls, only tend to
use it for processing integers/numbers and avoid it for regular
string concatenation (NOTE: we try to be a bit safer about it to
address earlier cited criticism, although we don't consider concatenating
3 or 4 characters at the end to be insecure)
(msg_hash_to_str) Try to avoid duplicate calls to the same localized
string when we can just cache the results once instead locally
This commit is contained in:
LibretroAdmin 2022-08-27 07:52:31 +02:00
parent 45b05ea3db
commit 61e24132bf
12 changed files with 250 additions and 160 deletions

View File

@ -1363,13 +1363,13 @@ static void load_timezone(char *setting)
char *start = strstr(haystack, needle); char *start = strstr(haystack, needle);
if (start != NULL) if (start)
snprintf(setting, TIMEZONE_LENGTH, "%s", start + needle_len); snprintf(setting, TIMEZONE_LENGTH, "%s", start + needle_len);
else else
snprintf(setting, TIMEZONE_LENGTH, "%s", DEFAULT_TIMEZONE); strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
} }
else else
snprintf(setting, TIMEZONE_LENGTH, "%s", DEFAULT_TIMEZONE); strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
config_set_timezone(setting); config_set_timezone(setting);
} }
@ -4697,16 +4697,26 @@ bool config_save_file(const char *path)
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
char cfg[64]; char cfg[64];
char formatted_number[4];
cfg[0] = '\0'; cfg[0] = formatted_number[0] = '\0';
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1); snprintf(formatted_number, sizeof(formatted_number), "%u", i + 1);
strlcpy(cfg, "input_device_p", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
config_set_int(conf, cfg, settings->uints.input_device[i]); config_set_int(conf, cfg, settings->uints.input_device[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1); strlcpy(cfg, "input_player", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
strlcat(cfg, "_joypad_index", sizeof(cfg));
config_set_int(conf, cfg, settings->uints.input_joypad_index[i]); config_set_int(conf, cfg, settings->uints.input_joypad_index[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1); strlcpy(cfg, "input_player", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
strlcat(cfg, "_analog_dpad_mode", sizeof(cfg));
config_set_int(conf, cfg, settings->uints.input_analog_dpad_mode[i]); config_set_int(conf, cfg, settings->uints.input_analog_dpad_mode[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_mouse_index", i + 1); strlcpy(cfg, "input_player", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
strlcat(cfg, "_mouse_index", sizeof(cfg));
config_set_int(conf, cfg, settings->uints.input_mouse_index[i]); config_set_int(conf, cfg, settings->uints.input_mouse_index[i]);
} }
@ -4964,19 +4974,25 @@ bool config_save_overrides(enum override_type type, void *data)
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
char cfg[64]; char cfg[64];
char formatted_number[4];
cfg[0] = formatted_number[0] = '\0';
snprintf(formatted_number, sizeof(formatted_number), "%u", i + 1);
cfg[0] = '\0';
if (settings->uints.input_device[i] if (settings->uints.input_device[i]
!= overrides->uints.input_device[i]) != overrides->uints.input_device[i])
{ {
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1); strlcpy(cfg, "input_device_p", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
config_set_int(conf, cfg, overrides->uints.input_device[i]); config_set_int(conf, cfg, overrides->uints.input_device[i]);
} }
if (settings->uints.input_joypad_index[i] if (settings->uints.input_joypad_index[i]
!= overrides->uints.input_joypad_index[i]) != overrides->uints.input_joypad_index[i])
{ {
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1); strlcpy(cfg, "input_player", sizeof(cfg));
strlcat(cfg, formatted_number, sizeof(cfg));
strlcpy(cfg, "_joypad_index", sizeof(cfg));
config_set_int(conf, cfg, overrides->uints.input_joypad_index[i]); config_set_int(conf, cfg, overrides->uints.input_joypad_index[i]);
} }
} }
@ -5117,13 +5133,17 @@ bool input_remapping_load_file(void *data, const char *path)
size_t _len; size_t _len;
char prefix[16]; char prefix[16];
char s1[32], s2[32], s3[32]; char s1[32], s2[32], s3[32];
char formatted_number[4];
prefix[0] = '\0'; prefix[0] = '\0';
s1[0] = '\0'; s1[0] = '\0';
s2[0] = '\0'; s2[0] = '\0';
s3[0] = '\0'; s3[0] = '\0';
formatted_number[0] = '\0';
snprintf(prefix, sizeof(prefix), "input_player%u", i + 1); snprintf(formatted_number, sizeof(formatted_number), "%u", i + 1);
strlcpy(prefix, "input_player", sizeof(prefix));
strlcat(prefix, formatted_number, sizeof(prefix));
_len = strlcpy(s1, prefix, sizeof(s1)); _len = strlcpy(s1, prefix, sizeof(s1));
s1[_len ] = '_'; s1[_len ] = '_';
s1[_len+1] = 'b'; s1[_len+1] = 'b';
@ -5204,13 +5224,17 @@ bool input_remapping_load_file(void *data, const char *path)
} }
} }
snprintf(s1, sizeof(s1), "input_player%u_analog_dpad_mode", i + 1); strlcpy(s1, "input_player", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
strlcat(s1, "_analog_dpad_mode", sizeof(s1));
CONFIG_GET_INT_BASE(conf, settings, uints.input_analog_dpad_mode[i], s1); CONFIG_GET_INT_BASE(conf, settings, uints.input_analog_dpad_mode[i], s1);
snprintf(s1, sizeof(s1), "input_libretro_device_p%u", i + 1); strlcpy(s1, "input_libretro_device_p", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], s1); CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], s1);
snprintf(s1, sizeof(s1), "input_remap_port_p%u", i + 1); strlcpy(s1, "input_remap_port_p", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
CONFIG_GET_INT_BASE(conf, settings, uints.input_remap_ports[i], s1); CONFIG_GET_INT_BASE(conf, settings, uints.input_remap_ports[i], s1);
} }
@ -5267,11 +5291,13 @@ bool input_remapping_save_file(const char *path)
{ {
size_t _len; size_t _len;
bool skip_port = true; bool skip_port = true;
char formatted_number[4];
char prefix[16]; char prefix[16];
char s1[32]; char s1[32];
char s2[32]; char s2[32];
char s3[32]; char s3[32];
formatted_number[4] = '\0';
prefix[0] = '\0'; prefix[0] = '\0';
s1[0] = '\0'; s1[0] = '\0';
s2[0] = '\0'; s2[0] = '\0';
@ -5298,7 +5324,9 @@ bool input_remapping_save_file(const char *path)
if (skip_port) if (skip_port)
continue; continue;
snprintf(prefix, sizeof(prefix), "input_player%u", i + 1); snprintf(formatted_number, sizeof(formatted_number), "%u", i + 1);
strlcpy(prefix, "input_player", sizeof(prefix));
strlcat(prefix, formatted_number, sizeof(prefix));
_len = strlcpy(s1, prefix, sizeof(s1)); _len = strlcpy(s1, prefix, sizeof(s1));
s1[_len ] = '_'; s1[_len ] = '_';
s1[_len+1] = 'b'; s1[_len+1] = 'b';
@ -5384,13 +5412,17 @@ bool input_remapping_save_file(const char *path)
settings->uints.input_keymapper_ids[i][j]); settings->uints.input_keymapper_ids[i][j]);
} }
snprintf(s1, sizeof(s1), "input_libretro_device_p%u", i + 1); strlcpy(s1, "input_libretro_device_p", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
config_set_int(conf, s1, input_config_get_device(i)); config_set_int(conf, s1, input_config_get_device(i));
snprintf(s1, sizeof(s1), "input_player%u_analog_dpad_mode", i + 1); strlcpy(s1, "input_player", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
strlcat(s1, "_analog_dpad_mode", sizeof(s1));
config_set_int(conf, s1, settings->uints.input_analog_dpad_mode[i]); config_set_int(conf, s1, settings->uints.input_analog_dpad_mode[i]);
snprintf(s1, sizeof(s1), "input_remap_port_p%u", i + 1); strlcpy(s1, "input_remap_port_p", sizeof(s1));
strlcat(s1, formatted_number, sizeof(s1));
config_set_int(conf, s1, settings->uints.input_remap_ports[i]); config_set_int(conf, s1, settings->uints.input_remap_ports[i]);
} }

View File

@ -1612,19 +1612,22 @@ static void core_info_resolve_firmware(
for (i = 0; i < firmware_count; i++) for (i = 0; i < firmware_count; i++)
{ {
char prefix[12];
char path_key[64]; char path_key[64];
char desc_key[64]; char desc_key[64];
char opt_key[64]; char opt_key[64];
struct config_entry_list *entry = NULL; struct config_entry_list *entry = NULL;
bool tmp_bool = false; bool tmp_bool = false;
path_key[0] = '\0'; prefix[0] = '\0';
desc_key[0] = '\0';
opt_key[0] = '\0';
snprintf(path_key, sizeof(path_key), "firmware%u_path", i); snprintf(prefix, sizeof(prefix), "firmware%u_", i);
snprintf(desc_key, sizeof(desc_key), "firmware%u_desc", i); strlcpy(path_key, prefix, sizeof(path_key));
snprintf(opt_key, sizeof(opt_key), "firmware%u_opt", i); strlcat(path_key, "path", sizeof(path_key));
strlcpy(desc_key, prefix, sizeof(desc_key));
strlcat(desc_key, "desc", sizeof(desc_key));
strlcpy(opt_key, prefix, sizeof(opt_key));
strlcat(opt_key, "opt", sizeof(opt_key));
entry = config_get_entry(conf, path_key); entry = config_get_entry(conf, path_key);

View File

@ -1998,8 +1998,13 @@ static void win32_localize_menu(HMENU menu)
if (new_label_text) if (new_label_text)
{ {
size_t _len;
new_label2 = new_label_text; new_label2 = new_label_text;
snprintf(new_label_text, buf_size, "%s\t%s", new_label, meta_key_name); _len = strlcpy(new_label_text, new_label,
buf_size);
new_label_text[_len ] = '\t';
new_label_text[_len+1] = '\0';
strlcat(new_label_text, meta_key_name, buf_size);
/* Make first character of shortcut name uppercase */ /* Make first character of shortcut name uppercase */
new_label_text[len1 + 1] = toupper(new_label_text[len1 + 1]); new_label_text[len1 + 1] = toupper(new_label_text[len1 + 1]);
} }

View File

@ -682,9 +682,9 @@ bool slang_reflect(
{ {
char buf[64]; char buf[64];
buf[0] = '\0'; strlcpy(buf, "[slang]:\n", sizeof(buf));
snprintf(buf, sizeof(buf), strlcat(buf, FILE_PATH_LOG_INFO, sizeof(buf));
"[slang]:\n%s [slang]: Parameters:\n", FILE_PATH_LOG_INFO); strlcat(buf, " [slang]: Parameters:\n", sizeof(buf));
RARCH_LOG(buf); RARCH_LOG(buf);
} }

View File

@ -982,11 +982,11 @@ void recording_dump_frame(
if ( vp.width != record_st->gpu_width || if ( vp.width != record_st->gpu_width ||
vp.height != record_st->gpu_height) vp.height != record_st->gpu_height)
{ {
RARCH_WARN("[Recording]: %s\n", const char *recording_failed_str =
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE)); msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE);
RARCH_WARN("[Recording]: %s\n", recording_failed_str);
runloop_msg_queue_push( runloop_msg_queue_push(recording_failed_str,
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE),
1, 180, true, 1, 180, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
command_event(CMD_EVENT_RECORD_DEINIT, NULL); command_event(CMD_EVENT_RECORD_DEINIT, NULL);

View File

@ -2531,17 +2531,22 @@ bool apply_shader(
if (message) if (message)
{ {
/* Display message */ /* Display message */
const char *msg_shader = msg_hash_to_str(MSG_SHADER);
size_t _len = strlcpy(msg, msg_shader, sizeof(msg));
msg[_len ] = ':';
msg[_len+1] = ' ';
msg[_len+2] = '\0';
if (preset_file) if (preset_file)
snprintf(msg, sizeof(msg), {
"%s: \"%s\"", msg[_len+2] = '"';
msg_hash_to_str(MSG_SHADER), msg[_len+3] = '\0';
preset_file); _len = strlcat(msg, preset_file, sizeof(msg));
msg[_len ] = '"';
msg[_len+1] = '\0';
}
else else
snprintf(msg, sizeof(msg), strlcat(msg, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE), sizeof(msg));
"%s: %s",
msg_hash_to_str(MSG_SHADER),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE)
);
#ifdef HAVE_GFX_WIDGETS #ifdef HAVE_GFX_WIDGETS
if (dispwidget_get_ptr()->active) if (dispwidget_get_ptr()->active)
gfx_widget_set_generic_message(msg, 2000); gfx_widget_set_generic_message(msg, 2000);

View File

@ -2234,28 +2234,32 @@ void input_config_get_bind_string_joykey(
} }
else else
{ {
const char *dir = "?"; const char *na_str =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
switch (GET_HAT_DIR(bind->joykey)) switch (GET_HAT_DIR(bind->joykey))
{ {
case HAT_UP_MASK: case HAT_UP_MASK:
dir = "up"; snprintf(buf, size, "%sHat #%u up (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_DOWN_MASK: case HAT_DOWN_MASK:
dir = "down"; snprintf(buf, size, "%sHat #%u down (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_LEFT_MASK: case HAT_LEFT_MASK:
dir = "left"; snprintf(buf, size, "%sHat #%u left (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_RIGHT_MASK: case HAT_RIGHT_MASK:
dir = "right"; snprintf(buf, size, "%sHat #%u right (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
default: default:
snprintf(buf, size, "%sHat #%u ? (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
} }
snprintf(buf, size, "%sHat #%u %s (%s)", prefix,
(unsigned)GET_HAT(bind->joykey), dir,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
} }
} }
else else
@ -2302,20 +2306,18 @@ void input_config_get_bind_string_joyaxis(
} }
else else
{ {
unsigned axis = 0; const char *na_str =
char dir = '\0'; msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE) if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
{ {
dir = '-'; unsigned axis = AXIS_NEG_GET(bind->joyaxis);
axis = AXIS_NEG_GET(bind->joyaxis); snprintf(buf, size, "%s-%u (%s)", prefix, axis, na_str);
} }
else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE) else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
{ {
dir = '+'; unsigned axis = AXIS_POS_GET(bind->joyaxis);
axis = AXIS_POS_GET(bind->joyaxis); snprintf(buf, size, "%s+%u (%s)", prefix, axis, na_str);
} }
snprintf(buf, size, "%s%c%u (%s)", prefix, dir, axis,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
} }
} }
@ -4668,23 +4670,16 @@ static bool runloop_check_movie_init(input_driver_state_t *input_st,
configuration_set_uint(settings, settings->uints.rewind_granularity, 1); configuration_set_uint(settings, settings->uints.rewind_granularity, 1);
strlcpy(path,
input_st->bsv_movie_state.movie_path, sizeof(path));
if (state_slot > 0) if (state_slot > 0)
{ {
path[0] = '\0'; char formatted_number[4];
snprintf(path, sizeof(path), "%s%d.bsv", formatted_number[0] = '\0';
input_st->bsv_movie_state.movie_path, snprintf(formatted_number, sizeof(formatted_number), "%d", state_slot);
state_slot); strlcat(path, formatted_number, sizeof(path));
}
else
{
size_t _len = strlcpy(path,
input_st->bsv_movie_state.movie_path, sizeof(path));
path[_len ] = '.';
path[_len+1] = 'b';
path[_len+2] = 's';
path[_len+3] = 'v';
path[_len+4] = '\0';
} }
strlcat(path, ".bsv", sizeof(path));
snprintf(msg, sizeof(msg), "%s \"%s\".", snprintf(msg, sizeof(msg), "%s \"%s\".",
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
@ -4772,6 +4767,7 @@ bool bsv_movie_init(input_driver_state_t *input_st)
bsv_movie_t *state = NULL; bsv_movie_t *state = NULL;
if (input_st->bsv_movie_state.movie_start_playback) if (input_st->bsv_movie_state.movie_start_playback)
{ {
const char *starting_movie_str = NULL;
if (!(state = bsv_movie_init_internal( if (!(state = bsv_movie_init_internal(
input_st->bsv_movie_state.movie_start_path, input_st->bsv_movie_state.movie_start_path,
RARCH_MOVIE_PLAYBACK))) RARCH_MOVIE_PLAYBACK)))
@ -4782,41 +4778,43 @@ bool bsv_movie_init(input_driver_state_t *input_st)
return false; return false;
} }
input_st->bsv_movie_state_handle = state; input_st->bsv_movie_state_handle = state;
input_st->bsv_movie_state.movie_playback = true; input_st->bsv_movie_state.movie_playback = true;
runloop_msg_queue_push(msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK), starting_movie_str =
msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK);
runloop_msg_queue_push(starting_movie_str,
2, 180, false, 2, 180, false,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK)); RARCH_LOG("%s.\n", starting_movie_str);
return true; return true;
} }
else if (input_st->bsv_movie_state.movie_start_recording) else if (input_st->bsv_movie_state.movie_start_recording)
{ {
char msg[8192]; char msg[8192];
const char *movie_rec_str = msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO);
if (!(state = bsv_movie_init_internal( if (!(state = bsv_movie_init_internal(
input_st->bsv_movie_state.movie_start_path, input_st->bsv_movie_state.movie_start_path,
RARCH_MOVIE_RECORD))) RARCH_MOVIE_RECORD)))
{ {
runloop_msg_queue_push( const char *movie_rec_fail_str =
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD);
runloop_msg_queue_push(movie_rec_fail_str,
1, 180, true, 1, 180, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_ERR("%s.\n", RARCH_ERR("%s.\n", movie_rec_fail_str);
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD));
return false; return false;
} }
input_st->bsv_movie_state_handle = state; input_st->bsv_movie_state_handle = state;
snprintf(msg, sizeof(msg), snprintf(msg, sizeof(msg),
"%s \"%s\".", "%s \"%s\".", movie_rec_str,
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
input_st->bsv_movie_state.movie_start_path); input_st->bsv_movie_state.movie_start_path);
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("%s \"%s\".\n", RARCH_LOG("%s \"%s\".\n", movie_rec_str,
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
input_st->bsv_movie_state.movie_start_path); input_st->bsv_movie_state.movie_start_path);
return true; return true;
@ -4835,18 +4833,21 @@ void bsv_movie_deinit(input_driver_state_t *input_st)
bool bsv_movie_check(input_driver_state_t *input_st, bool bsv_movie_check(input_driver_state_t *input_st,
settings_t *settings) settings_t *settings)
{ {
const char *movie_rec_stopped_str = NULL;
if (!input_st->bsv_movie_state_handle) if (!input_st->bsv_movie_state_handle)
return runloop_check_movie_init(input_st, settings); return runloop_check_movie_init(input_st, settings);
if (input_st->bsv_movie_state.movie_playback) if (input_st->bsv_movie_state.movie_playback)
{ {
const char *movie_playback_end_str = NULL;
/* Checks if movie is being played back. */ /* Checks if movie is being played back. */
if (!input_st->bsv_movie_state.movie_end) if (!input_st->bsv_movie_state.movie_end)
return false; return false;
movie_playback_end_str = msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED);
runloop_msg_queue_push( runloop_msg_queue_push(
msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 2, 180, false, movie_playback_end_str, 2, 180, false,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); RARCH_LOG("%s\n", movie_playback_end_str);
bsv_movie_deinit(input_st); bsv_movie_deinit(input_st);
@ -4860,10 +4861,11 @@ bool bsv_movie_check(input_driver_state_t *input_st,
if (!input_st->bsv_movie_state_handle) if (!input_st->bsv_movie_state_handle)
return false; return false;
runloop_msg_queue_push( movie_rec_stopped_str = msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED);
msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true, runloop_msg_queue_push(movie_rec_stopped_str,
2, 180, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); RARCH_LOG("%s\n", movie_rec_stopped_str);
bsv_movie_deinit(input_st); bsv_movie_deinit(input_st);

View File

@ -3810,6 +3810,7 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
if ((playlist && (ozone->is_playlist || (ozone->is_quick_menu && !menu_is_running_quick_menu()))) || if ((playlist && (ozone->is_playlist || (ozone->is_quick_menu && !menu_is_running_quick_menu()))) ||
(ozone->is_db_manager_list && ozone->depth == 4)) (ozone->is_db_manager_list && ozone->depth == 4))
{ {
size_t _len;
const char *core_label = NULL; const char *core_label = NULL;
const struct playlist_entry *entry = NULL; const struct playlist_entry *entry = NULL;
size_t list_size = menu_entries_get_size(); size_t list_size = menu_entries_get_size();
@ -3875,8 +3876,13 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
core_label = core_name; core_label = core_name;
} }
snprintf(ozone->selection_core_name, sizeof(ozone->selection_core_name), _len = strlcpy(ozone->selection_core_name,
"%s %s", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), core_label); msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
sizeof(ozone->selection_core_name));
ozone->selection_core_name[_len ] = ' ';
ozone->selection_core_name[_len+1] = '\0';
strlcat(ozone->selection_core_name, core_label,
sizeof(ozone->selection_core_name));
if (!scroll_content_metadata) if (!scroll_content_metadata)
linebreak_after_colon(&ozone->selection_core_name); linebreak_after_colon(&ozone->selection_core_name);
@ -3917,13 +3923,27 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
} }
else else
{ {
snprintf(ozone->selection_playtime, sizeof(ozone->selection_playtime), "%s %s", const char *disabled_str =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); size_t _len =
strlcpy(ozone->selection_playtime,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
sizeof(ozone->selection_playtime));
ozone->selection_playtime[_len ] = ' ';
ozone->selection_playtime[_len+1] = '\0';
strlcat(ozone->selection_playtime, disabled_str,
sizeof(ozone->selection_playtime));
snprintf(ozone->selection_lastplayed, sizeof(ozone->selection_lastplayed), "%s %s", _len =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), strlcpy(ozone->selection_lastplayed,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
sizeof(ozone->selection_lastplayed));
ozone->selection_lastplayed[_len ] = ' ';
ozone->selection_lastplayed[_len+1] = '\0';
strlcat(ozone->selection_lastplayed, disabled_str,
sizeof(ozone->selection_lastplayed));
} }
if (!scroll_content_metadata) if (!scroll_content_metadata)

View File

@ -2224,6 +2224,7 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_HISTORY_INIT: case CMD_EVENT_HISTORY_INIT:
{ {
playlist_config_t playlist_config; playlist_config_t playlist_config;
const char *_msg = NULL;
bool history_list_enable = settings->bools.history_list_enable; bool history_list_enable = settings->bools.history_list_enable;
const char *path_content_history = settings->paths.path_content_history; const char *path_content_history = settings->paths.path_content_history;
const char *path_content_music_history = settings->paths.path_content_music_history; const char *path_content_music_history = settings->paths.path_content_music_history;
@ -2245,18 +2246,18 @@ bool command_event(enum event_command cmd, void *data)
if (!history_list_enable) if (!history_list_enable)
return false; return false;
_msg = msg_hash_to_str(MSG_LOADING_HISTORY_FILE);
/* Note: Sorting is disabled by default for /* Note: Sorting is disabled by default for
* all content history playlists */ * all content history playlists */
RARCH_LOG("[Playlist]: %s: \"%s\".\n", RARCH_LOG("[Playlist]: %s: \"%s\".\n", _msg,
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_history); path_content_history);
playlist_config_set_path(&playlist_config, path_content_history); playlist_config_set_path(&playlist_config, path_content_history);
g_defaults.content_history = playlist_init(&playlist_config); g_defaults.content_history = playlist_init(&playlist_config);
playlist_set_sort_mode( playlist_set_sort_mode(
g_defaults.content_history, PLAYLIST_SORT_MODE_OFF); g_defaults.content_history, PLAYLIST_SORT_MODE_OFF);
RARCH_LOG("[Playlist]: %s: \"%s\".\n", RARCH_LOG("[Playlist]: %s: \"%s\".\n", _msg,
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_music_history); path_content_music_history);
playlist_config_set_path(&playlist_config, path_content_music_history); playlist_config_set_path(&playlist_config, path_content_music_history);
g_defaults.music_history = playlist_init(&playlist_config); g_defaults.music_history = playlist_init(&playlist_config);
@ -2264,8 +2265,7 @@ bool command_event(enum event_command cmd, void *data)
g_defaults.music_history, PLAYLIST_SORT_MODE_OFF); g_defaults.music_history, PLAYLIST_SORT_MODE_OFF);
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) #if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
RARCH_LOG("[Playlist]: %s: \"%s\".\n", RARCH_LOG("[Playlist]: %s: \"%s\".\n", _msg,
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_video_history); path_content_video_history);
playlist_config_set_path(&playlist_config, path_content_video_history); playlist_config_set_path(&playlist_config, path_content_video_history);
g_defaults.video_history = playlist_init(&playlist_config); g_defaults.video_history = playlist_init(&playlist_config);
@ -2274,8 +2274,7 @@ bool command_event(enum event_command cmd, void *data)
#endif #endif
#ifdef HAVE_IMAGEVIEWER #ifdef HAVE_IMAGEVIEWER
RARCH_LOG("[Playlist]: %s: \"%s\".\n", RARCH_LOG("[Playlist]: %s: \"%s\".\n", _msg,
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_image_history); path_content_image_history);
playlist_config_set_path(&playlist_config, path_content_image_history); playlist_config_set_path(&playlist_config, path_content_image_history);
g_defaults.image_history = playlist_init(&playlist_config); g_defaults.image_history = playlist_init(&playlist_config);

View File

@ -3445,10 +3445,11 @@ static bool init_libretro_symbols_custom(
path_get_realsize(RARCH_PATH_CORE) path_get_realsize(RARCH_PATH_CORE)
))) )))
{ {
RARCH_ERR("%s: \"%s\"\nError(s): %s\n", const char *failed_open_str =
msg_hash_to_str(MSG_FAILED_TO_OPEN_LIBRETRO_CORE), msg_hash_to_str(MSG_FAILED_TO_OPEN_LIBRETRO_CORE);
RARCH_ERR("%s: \"%s\"\nError(s): %s\n", failed_open_str,
path, dylib_error()); path, dylib_error());
runloop_msg_queue_push(msg_hash_to_str(MSG_FAILED_TO_OPEN_LIBRETRO_CORE), runloop_msg_queue_push(failed_open_str,
1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
return false; return false;
} }
@ -4771,9 +4772,11 @@ static void do_runahead(
if (!runahead_create(runloop_st)) if (!runahead_create(runloop_st))
{ {
const char *runahead_failed_str =
msg_hash_to_str(MSG_RUNAHEAD_CORE_DOES_NOT_SUPPORT_SAVESTATES);
if (!runahead_hide_warnings) if (!runahead_hide_warnings)
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_CORE_DOES_NOT_SUPPORT_SAVESTATES), 0, 2 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(runahead_failed_str, 0, 2 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_CORE_DOES_NOT_SUPPORT_SAVESTATES)); RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
goto force_input_dirty; goto force_input_dirty;
} }
} }
@ -4817,8 +4820,10 @@ static void do_runahead(
{ {
if (!runahead_save_state(runloop_st)) if (!runahead_save_state(runloop_st))
{ {
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE), 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); const char *runahead_failed_str =
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE)); msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE);
runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
return; return;
} }
} }
@ -4827,8 +4832,10 @@ static void do_runahead(
{ {
if (!runahead_load_state(runloop_st)) if (!runahead_load_state(runloop_st))
{ {
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE), 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); const char *runahead_failed_str =
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE)); msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE);
runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
return; return;
} }
} }
@ -4839,10 +4846,12 @@ static void do_runahead(
#if HAVE_DYNAMIC #if HAVE_DYNAMIC
if (!secondary_core_ensure_exists(config_get_ptr())) if (!secondary_core_ensure_exists(config_get_ptr()))
{ {
const char *runahead_failed_str =
msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_CREATE_SECONDARY_INSTANCE);
runloop_secondary_core_destroy(); runloop_secondary_core_destroy();
runloop_st->runahead_secondary_core_available = false; runloop_st->runahead_secondary_core_available = false;
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_CREATE_SECONDARY_INSTANCE), 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_CREATE_SECONDARY_INSTANCE)); RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
goto force_input_dirty; goto force_input_dirty;
} }
@ -4858,15 +4867,19 @@ static void do_runahead(
if (!runahead_save_state(runloop_st)) if (!runahead_save_state(runloop_st))
{ {
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE), 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); const char *runahead_failed_str =
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE)); msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_SAVE_STATE);
runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
return; return;
} }
if (!runahead_load_state_secondary()) if (!runahead_load_state_secondary())
{ {
runloop_msg_queue_push(msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE), 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); const char *runahead_failed_str =
RARCH_WARN("[Run-Ahead]: %s\n", msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE)); msg_hash_to_str(MSG_RUNAHEAD_FAILED_TO_LOAD_STATE);
runloop_msg_queue_push(runahead_failed_str, 0, 3 * 60, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_WARN("[Run-Ahead]: %s\n", runahead_failed_str);
return; return;
} }
@ -8127,7 +8140,8 @@ bool retroarch_get_entry_state_path(char *path, size_t len, unsigned slot)
if (string_is_empty(name_savestate)) if (string_is_empty(name_savestate))
return false; return false;
snprintf(path, len, "%s%d%s", name_savestate, slot, ".entry"); snprintf(path, len, "%s%d", name_savestate, slot);
strlcat(path, ".entry", len);
return true; return true;
} }

View File

@ -687,6 +687,8 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
float periods[6] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f}; float periods[6] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f};
tmp[0] = '\0';
if (!runtime_log) if (!runtime_log)
return false; return false;
@ -703,10 +705,13 @@ static bool runtime_last_played_human(runtime_log_t *runtime_log,
delta /= periods[i]; delta /= periods[i];
/* Generate string */ /* Generate string */
snprintf(tmp, sizeof(tmp), "%u %s", snprintf(tmp, sizeof(tmp), "%u ", (int)delta);
(int)delta, msg_hash_to_str((delta == 1) if (delta == 1)
? (enum msg_hash_enums)units[i][0] strlcat(tmp, msg_hash_to_str((enum msg_hash_enums)units[i][0]),
: (enum msg_hash_enums)units[i][1])); sizeof(tmp));
else
strlcat(tmp, msg_hash_to_str((enum msg_hash_enums)units[i][1]),
sizeof(tmp));
strlcat(str, tmp, len); strlcat(str, tmp, len);
strlcat(str, " ", len); strlcat(str, " ", len);
strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TIME_UNIT_AGO), len); strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TIME_UNIT_AGO), len);

View File

@ -783,18 +783,22 @@ static void task_save_handler(retro_task_t *task)
if (state->undo_save) if (state->undo_save)
{ {
RARCH_ERR("[State]: %s \"%s\".\n", const char *failed_undo_str = msg_hash_to_str(
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE), MSG_FAILED_TO_UNDO_SAVE_STATE);
RARCH_ERR("[State]: %s \"%s\".\n", failed_undo_str,
undo_save_buf.path); undo_save_buf.path);
snprintf(err, err_size - 1, "%s \"%s\".", snprintf(err, err_size - 1, "%s \"RAM\".", failed_undo_str);
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE),
"RAM");
} }
else else
snprintf(err, err_size - 1, {
"%s %s", size_t _len = strlcpy(err,
msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), state->path); msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO),
err_size - 1);
err[_len ] = ' ';
err[_len+1] = '\0';
strlcat(err, state->path, err_size - 1);
}
task_set_error(task, strdup(err)); task_set_error(task, strdup(err));
free(err); free(err);
@ -817,7 +821,8 @@ static void task_save_handler(retro_task_t *task)
char new_msg[128]; char new_msg[128];
new_msg[0] = '\0'; new_msg[0] = '\0';
snprintf(new_msg, sizeof(new_msg), msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT), snprintf(new_msg, sizeof(new_msg),
msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT),
state->state_slot); state->state_slot);
msg = strdup(new_msg); msg = strdup(new_msg);
} }
@ -1878,8 +1883,8 @@ static bool dump_to_file_desperate(const void *data,
bool content_load_state_from_ram(void) bool content_load_state_from_ram(void)
{ {
size_t temp_data_size; size_t temp_data_size;
bool ret = false; bool ret = false;
void* temp_data = NULL; void* temp_data = NULL;
if (!core_info_current_supports_savestate()) if (!core_info_current_supports_savestate())
{ {
@ -1897,19 +1902,19 @@ bool content_load_state_from_ram(void)
msg_hash_to_str(MSG_BYTES)); msg_hash_to_str(MSG_BYTES));
/* We need to make a temporary copy of the buffer, to allow the swap below */ /* We need to make a temporary copy of the buffer, to allow the swap below */
temp_data = malloc(ram_buf.state_buf.size); temp_data = malloc(ram_buf.state_buf.size);
temp_data_size = ram_buf.state_buf.size; temp_data_size = ram_buf.state_buf.size;
memcpy(temp_data, ram_buf.state_buf.data, ram_buf.state_buf.size); memcpy(temp_data, ram_buf.state_buf.data, ram_buf.state_buf.size);
/* Swap the current state with the backup state. This way, we can undo /* Swap the current state with the backup state. This way, we can undo
what we're undoing */ what we're undoing */
content_save_state("RAM", false, false); content_save_state("RAM", false, false);
ret = content_deserialize_state(temp_data, temp_data_size); ret = content_deserialize_state(temp_data, temp_data_size);
/* Clean up the temporary copy */ /* Clean up the temporary copy */
free(temp_data); free(temp_data);
temp_data = NULL; temp_data = NULL;
if (!ret) if (!ret)
{ {
@ -1922,9 +1927,9 @@ bool content_load_state_from_ram(void)
/** /**
* content_save_state_from_ram: * content_save_state_from_ram:
* Save a state to ram. * Save a state to RAM.
* *
* Returns: true if successful, false otherwise. * @return true if successful, false otherwise.
**/ **/
bool content_save_state_to_ram(void) bool content_save_state_to_ram(void)
{ {
@ -1947,9 +1952,7 @@ bool content_save_state_to_ram(void)
if (!save_state_in_background) if (!save_state_in_background)
{ {
data = content_get_serialized_data(&serial_size); if (!(data = content_get_serialized_data(&serial_size)))
if (!data)
{ {
RARCH_ERR("[State]: %s.\n", RARCH_ERR("[State]: %s.\n",
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));
@ -1962,14 +1965,14 @@ bool content_save_state_to_ram(void)
msg_hash_to_str(MSG_BYTES)); msg_hash_to_str(MSG_BYTES));
} }
if (!data)
data = content_get_serialized_data(&serial_size);
if (!data) if (!data)
{ {
RARCH_ERR("[State]: %s.\n", if (!(data = content_get_serialized_data(&serial_size)))
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); {
return false; RARCH_ERR("[State]: %s.\n",
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));
return false;
}
} }
/* If we were holding onto an old state already, clean it up first */ /* If we were holding onto an old state already, clean it up first */
@ -1979,8 +1982,7 @@ bool content_save_state_to_ram(void)
ram_buf.state_buf.data = NULL; ram_buf.state_buf.data = NULL;
} }
ram_buf.state_buf.data = malloc(serial_size); if (!(ram_buf.state_buf.data = malloc(serial_size)))
if (!ram_buf.state_buf.data)
{ {
free(data); free(data);
return false; return false;
@ -1989,7 +1991,7 @@ bool content_save_state_to_ram(void)
memcpy(ram_buf.state_buf.data, data, serial_size); memcpy(ram_buf.state_buf.data, data, serial_size);
free(data); free(data);
ram_buf.state_buf.size = serial_size; ram_buf.state_buf.size = serial_size;
ram_buf.to_write_file = true; ram_buf.to_write_file = true;
return true; return true;
} }
@ -1997,19 +1999,19 @@ bool content_save_state_to_ram(void)
/** /**
* content_ram_state_to_file: * content_ram_state_to_file:
* @path : path of ram state that shall be written to. * @path : path of ram state that shall be written to.
* Save a ram state from memory to disk. * Save a RAM state from memory to disk.
* *
* Returns: true if successful, false otherwise. * @return true if successful, false otherwise.
**/ **/
bool content_ram_state_to_file(const char *path) bool content_ram_state_to_file(const char *path)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
#if defined(HAVE_ZLIB) #if defined(HAVE_ZLIB)
bool compress_files = settings->bools.save_file_compression; bool compress_files = settings->bools.save_file_compression;
#else #else
bool compress_files = false; bool compress_files = false;
#endif #endif
bool write_success; bool write_success = false;
if (!path) if (!path)
return false; return false;
@ -2030,9 +2032,12 @@ bool content_ram_state_to_file(const char *path)
path, ram_buf.state_buf.data, ram_buf.state_buf.size); path, ram_buf.state_buf.data, ram_buf.state_buf.size);
if (write_success) if (write_success)
{
ram_buf.to_write_file = false; ram_buf.to_write_file = false;
return true;
}
return write_success; return false;
} }
/** /**