len variable/argument name standardization

This commit is contained in:
LibretroAdmin 2025-01-15 16:04:25 +01:00
parent 076c2bca3b
commit 9da7af46c3
12 changed files with 113 additions and 132 deletions

View File

@ -115,7 +115,7 @@ HRESULT WINAPI
} }
#endif #endif
bool d3d_compile(const char* src, size_t size, bool d3d_compile(const char* src, size_t len,
LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out) LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out)
{ {
D3DBlob error_msg; D3DBlob error_msg;
@ -125,11 +125,11 @@ bool d3d_compile(const char* src, size_t size,
UINT compileflags = 0; UINT compileflags = 0;
#endif #endif
if (!size) if (!len)
size = strlen(src); len = strlen(src);
if (FAILED(D3DCompile( if (FAILED(D3DCompile(
src, size, src_name, NULL, NULL, src, len, src_name, NULL, NULL,
entrypoint, target, compileflags, 0, out, &error_msg))) entrypoint, target, compileflags, 0, out, &error_msg)))
{ {
if (error_msg) if (error_msg)

View File

@ -24,7 +24,7 @@
typedef ID3DBlob* D3DBlob; typedef ID3DBlob* D3DBlob;
bool d3d_compile(const char* src, size_t size, bool d3d_compile(const char* src, size_t len,
LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out);
bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out);

View File

@ -194,12 +194,11 @@ static bool wiiu_hid_joypad_rumble(void *data, unsigned slot,
return false; return false;
} }
static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t size) static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t len)
{ {
void *result = memalign(alignment, size); void *result = memalign(alignment, len);
if (result) if (result)
memset(result, 0, size); memset(result, 0, len);
return result; return result;
} }
@ -749,7 +748,7 @@ static void wiiu_hid_poll(void *data)
synchronized_process_adapters(hid); synchronized_process_adapters(hid);
} }
static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t len)
{ {
wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; wiiu_adapter_t *adapter = (wiiu_adapter_t *)data;
int32_t result; int32_t result;
@ -761,7 +760,7 @@ static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size)
} }
memset(adapter->tx_buffer, 0, adapter->tx_size); memset(adapter->tx_buffer, 0, adapter->tx_size);
memcpy(adapter->tx_buffer, buf, size); memcpy(adapter->tx_buffer, buf, len);
/* From testing, HIDWrite returns an error that looks like it's two /* From testing, HIDWrite returns an error that looks like it's two
* int16_t's bitmasked together. For example, one error I saw when trying * int16_t's bitmasked together. For example, one error I saw when trying
@ -848,24 +847,19 @@ static int32_t wiiu_hid_set_protocol(void *data, uint8_t protocol)
NULL, NULL); NULL, NULL);
} }
static int32_t wiiu_hid_read(void *data, void *buffer, size_t size) static int32_t wiiu_hid_read(void *data, void *buffer, size_t len)
{ {
wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; wiiu_adapter_t *adapter = (wiiu_adapter_t *)data;
int32_t result; int32_t result;
if (!adapter) if (!adapter)
return -1; return -1;
if (len > adapter->rx_size)
if (size > adapter->rx_size)
return -1; return -1;
if ((result = HIDRead(adapter->handle, buffer, len, NULL, NULL)) < 0)
if ((result = HIDRead(adapter->handle, buffer, size, NULL, NULL)) < 0)
wiiu_hid_report_hid_error("read failed", adapter, result); wiiu_hid_report_hid_error("read failed", adapter, result);
return result; return result;
} }
static void wiiu_hid_init_cachealigned_buffer(int32_t min_size, uint8_t **out_buf_ptr, int32_t *actual_size) static void wiiu_hid_init_cachealigned_buffer(int32_t min_size, uint8_t **out_buf_ptr, int32_t *actual_size)
{ {
*actual_size = (min_size + 0x3f) & ~0x3f; *actual_size = (min_size + 0x3f) & ~0x3f;

View File

@ -930,14 +930,14 @@ static int _rjson_buffer_io(void* buf, int len, void *user)
return len; return len;
} }
rjson_t *rjson_open_buffer(const void *buffer, size_t size) rjson_t *rjson_open_buffer(const void *buffer, size_t len)
{ {
rjson_t *json = (rjson_t *)malloc(sizeof(rjson_t) + sizeof(const char *)*2); rjson_t *json = (rjson_t *)malloc(sizeof(rjson_t) + sizeof(const char *)*2);
const char **ud = (const char **)(json + 1); const char **ud = (const char **)(json + 1);
if (!json) if (!json)
return NULL; return NULL;
ud[0] = (const char *)buffer; ud[0] = (const char *)buffer;
ud[1] = ud[0] + size; ud[1] = ud[0] + len;
_rjson_setup(json, _rjson_buffer_io, (void*)ud, sizeof(json->input_buf)); _rjson_setup(json, _rjson_buffer_io, (void*)ud, sizeof(json->input_buf));
return json; return json;
} }

View File

@ -67,7 +67,7 @@ struct RFILE;
/* Create a new parser instance from various sources */ /* Create a new parser instance from various sources */
rjson_t *rjson_open_stream(struct intfstream_internal *stream); rjson_t *rjson_open_stream(struct intfstream_internal *stream);
rjson_t *rjson_open_rfile(struct RFILE *rfile); rjson_t *rjson_open_rfile(struct RFILE *rfile);
rjson_t *rjson_open_buffer(const void *buffer, size_t size); rjson_t *rjson_open_buffer(const void *buffer, size_t len);
rjson_t *rjson_open_string(const char *string, size_t len); rjson_t *rjson_open_string(const char *string, size_t len);
rjson_t *rjson_open_user(rjson_io_t io, void *user_data, int io_block_size); rjson_t *rjson_open_user(rjson_io_t io, void *user_data, int io_block_size);

View File

@ -39,13 +39,9 @@
#include <streams/stdin_stream.h> #include <streams/stdin_stream.h>
#if (defined(_WIN32) && defined(_XBOX)) || defined(__WINRT__) || !defined(__PSL1GHT__) && defined(__PS3__) #if (defined(_WIN32) && defined(_XBOX)) || defined(__WINRT__) || !defined(__PSL1GHT__) && defined(__PS3__)
size_t read_stdin(char *buf, size_t size) size_t read_stdin(char *buf, size_t len) { return 0; } /* not implemented */
{
/* Not implemented. */
return 0;
}
#elif defined(_WIN32) #elif defined(_WIN32)
size_t read_stdin(char *buf, size_t size) size_t read_stdin(char *buf, size_t len)
{ {
DWORD i; DWORD i;
DWORD has_read = 0; DWORD has_read = 0;
@ -90,7 +86,7 @@ size_t read_stdin(char *buf, size_t size)
{ {
has_key = true; has_key = true;
echo = true; echo = true;
avail = size; avail = len;
break; break;
} }
} }
@ -105,8 +101,8 @@ size_t read_stdin(char *buf, size_t size)
if (!avail) if (!avail)
return 0; return 0;
if (avail > size) if (avail > len)
avail = size; avail = len;
if (!ReadFile(hnd, buf, avail, &has_read, NULL)) if (!ReadFile(hnd, buf, avail, &has_read, NULL))
return 0; return 0;
@ -130,22 +126,18 @@ size_t read_stdin(char *buf, size_t size)
return has_read; return has_read;
} }
#else #else
size_t read_stdin(char *buf, size_t size) size_t read_stdin(char *buf, size_t len)
{ {
size_t has_read = 0; size_t has_read = 0;
while (len)
while (size)
{ {
ssize_t ret = read(STDIN_FILENO, buf, size); ssize_t ret = read(STDIN_FILENO, buf, len);
if (ret <= 0) if (ret <= 0)
break; break;
buf += ret; buf += ret;
has_read += ret; has_read += ret;
size -= ret; len -= ret;
} }
return has_read; return has_read;
} }
#endif #endif

View File

@ -28,8 +28,8 @@
* for the new stream data to be saved * for the new stream data to be saved
* @in : input data * @in : input data
* @in_size : input size * @in_size : input size
* @out : output data * @s : output data
* @out_size : output size * @len : output size
* @error : (optional) output for error code * @error : (optional) output for error code
* *
* Perform a full transcoding from a source to a destination. * Perform a full transcoding from a source to a destination.
@ -37,7 +37,7 @@
bool trans_stream_trans_full( bool trans_stream_trans_full(
struct trans_stream_backend *backend, void **data, struct trans_stream_backend *backend, void **data,
const uint8_t *in, uint32_t in_size, const uint8_t *in, uint32_t in_size,
uint8_t *out, uint32_t out_size, uint8_t *s, uint32_t len,
enum trans_stream_error *error) enum trans_stream_error *error)
{ {
void *rdata; void *rdata;
@ -57,7 +57,7 @@ bool trans_stream_trans_full(
} }
backend->set_in(rdata, in, in_size); backend->set_in(rdata, in, in_size);
backend->set_out(rdata, out, out_size); backend->set_out(rdata, s, len);
ret = backend->trans(rdata, true, &rd, &wn, error); ret = backend->trans(rdata, true, &rd, &wn, error);
if (data) if (data)

8
save.c
View File

@ -152,7 +152,7 @@ static void autosave_thread(void *data)
* autosave_new: * autosave_new:
* @path : path to autosave file * @path : path to autosave file
* @data : pointer to buffer * @data : pointer to buffer
* @size : size of @data buffer * @len : size of @data buffer
* @interval : interval at which saves should be performed. * @interval : interval at which saves should be performed.
* *
* Create and initialize autosave object. * Create and initialize autosave object.
@ -161,7 +161,7 @@ static void autosave_thread(void *data)
* NULL. * NULL.
**/ **/
static autosave_t *autosave_new(const char *path, static autosave_t *autosave_new(const char *path,
const void *data, size_t size, const void *data, size_t len,
unsigned interval, bool compress) unsigned interval, bool compress)
{ {
void *buf = NULL; void *buf = NULL;
@ -170,14 +170,14 @@ static autosave_t *autosave_new(const char *path,
return NULL; return NULL;
handle->flags = 0; handle->flags = 0;
handle->bufsize = size; handle->bufsize = len;
handle->interval = interval; handle->interval = interval;
if (compress) if (compress)
handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES; handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES;
handle->retro_buffer = data; handle->retro_buffer = data;
handle->path = path; handle->path = path;
if (!(buf = malloc(size))) if (!(buf = malloc(len)))
{ {
free(handle); free(handle);
return NULL; return NULL;

View File

@ -205,8 +205,8 @@ static size_t state_manager_raw_maxsize(size_t uncomp)
*/ */
static void *state_manager_raw_alloc(size_t len, uint16_t uniq) static void *state_manager_raw_alloc(size_t len, uint16_t uniq)
{ {
size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); size_t _len = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t);
uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1); uint16_t *ret = (uint16_t*)calloc(_len + sizeof(uint16_t) * 4 + 16, 1);
if (!ret) if (!ret)
return NULL; return NULL;
@ -222,7 +222,7 @@ static void *state_manager_raw_alloc(size_t len, uint16_t uniq)
* *
* It doesn't make any difference to us, but sacrificing 16 bytes to get * It doesn't make any difference to us, but sacrificing 16 bytes to get
* Valgrind happy is worth it. */ * Valgrind happy is worth it. */
ret[len16/sizeof(uint16_t) + 3] = uniq; ret[_len / sizeof(uint16_t) + 3] = uniq;
return ret; return ret;
} }
@ -301,8 +301,7 @@ static size_t state_manager_raw_compress(const void *src,
* If the given arguments do not match a previous call to * If the given arguments do not match a previous call to
* state_manager_raw_compress(), anything at all can happen. * state_manager_raw_compress(), anything at all can happen.
*/ */
static void state_manager_raw_decompress(const void *patch, static void state_manager_raw_decompress(const void *patch, void *data)
size_t patchlen, void *data, size_t datalen)
{ {
uint16_t *out16 = (uint16_t*)data; uint16_t *out16 = (uint16_t*)data;
const uint16_t *patch16 = (const uint16_t*)patch; const uint16_t *patch16 = (const uint16_t*)patch;
@ -473,8 +472,7 @@ static bool state_manager_pop(state_manager_t *state, const void **data)
compressed = state->data + start + sizeof(size_t); compressed = state->data + start + sizeof(size_t);
out = state->thisblock; out = state->thisblock;
state_manager_raw_decompress(compressed, state_manager_raw_decompress(compressed, out);
state->maxcompsize, out, state->blocksize);
state->entries--; state->entries--;
return true; return true;
@ -512,8 +510,8 @@ static void state_manager_push_do(state_manager_t *state)
if (state->thisblock_valid) if (state->thisblock_valid)
{ {
const uint8_t *oldb, *newb;
uint8_t *compressed; uint8_t *compressed;
const uint8_t *oldb, *newb;
size_t headpos, tailpos, remaining; size_t headpos, tailpos, remaining;
if (state->capacity < sizeof(size_t) + state->maxcompsize) { if (state->capacity < sizeof(size_t) + state->maxcompsize) {
RARCH_ERR("State capacity insufficient\n"); RARCH_ERR("State capacity insufficient\n");

View File

@ -371,19 +371,20 @@ size_t content_get_serialized_size(void)
rastate_size_info_t size; rastate_size_info_t size;
return content_get_rastate_size(&size, false); return content_get_rastate_size(&size, false);
} }
size_t content_get_serialized_size_rewind(void) size_t content_get_serialized_size_rewind(void)
{ {
rastate_size_info_t size; rastate_size_info_t size;
return content_get_rastate_size(&size, true); return content_get_rastate_size(&size, true);
} }
static void content_write_block_header(unsigned char* output, const char* header, size_t size) static void content_write_block_header(unsigned char* output, const char* header, size_t len)
{ {
memcpy(output, header, 4); memcpy(output, header, 4);
output[4] = ((size) & 0xFF); output[4] = ((len) & 0xFF);
output[5] = ((size >> 8) & 0xFF); output[5] = ((len >> 8) & 0xFF);
output[6] = ((size >> 16) & 0xFF); output[6] = ((len >> 16) & 0xFF);
output[7] = ((size >> 24) & 0xFF); output[7] = ((len >> 24) & 0xFF);
} }
static bool content_write_serialized_state(void* buffer, static bool content_write_serialized_state(void* buffer,
@ -523,9 +524,9 @@ static void task_save_handler(retro_task_t *task)
if (!state->data) if (!state->data)
{ {
size_t size = 0; size_t _len = 0;
state->data = content_get_serialized_data(&size); state->data = content_get_serialized_data(&_len);
state->size = (ssize_t)size; state->size = (ssize_t)_len;
} }
remaining = MIN(state->size - state->written, SAVE_STATE_CHUNK); remaining = MIN(state->size - state->written, SAVE_STATE_CHUNK);
@ -608,7 +609,7 @@ static void task_save_handler(retro_task_t *task)
* *
* Create a new task to undo the last save of the content state. * Create a new task to undo the last save of the content state.
**/ **/
static bool task_push_undo_save_state(const char *path, void *data, size_t size) static bool task_push_undo_save_state(const char *path, void *data, size_t len)
{ {
settings_t *settings; settings_t *settings;
retro_task_t *task = task_init(); retro_task_t *task = task_init();
@ -623,7 +624,7 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size)
strlcpy(state->path, path, sizeof(state->path)); strlcpy(state->path, path, sizeof(state->path));
state->data = data; state->data = data;
state->size = size; state->size = len;
state->flags |= SAVE_TASK_FLAG_UNDO_SAVE; state->flags |= SAVE_TASK_FLAG_UNDO_SAVE;
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;
if (video_st->frame_cache_data && (video_st->frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID)) if (video_st->frame_cache_data && (video_st->frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID))
@ -829,9 +830,9 @@ end:
task_load_handler_finished(task, state); task_load_handler_finished(task, state);
} }
static bool content_load_rastate1(unsigned char* input, size_t size) static bool content_load_rastate1(unsigned char* input, size_t len)
{ {
unsigned char *stop = input + size; unsigned char *stop = input + len;
bool seen_core = false; bool seen_core = false;
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
bool seen_cheevos = false; bool seen_cheevos = false;
@ -934,18 +935,16 @@ static bool content_load_rastate1(unsigned char* input, size_t size)
return true; return true;
} }
bool content_deserialize_state( bool content_deserialize_state(const void *s, size_t len)
const void* serialized_data, size_t serialized_size)
{ {
if (memcmp(serialized_data, "RASTATE", 7) != 0) if (memcmp(s, "RASTATE", 7) != 0)
{ {
/* old format is just core data, load it directly */ /* old format is just core data, load it directly */
retro_ctx_serialize_info_t serial_info; retro_ctx_serialize_info_t serial_info;
serial_info.data_const = serialized_data; serial_info.data_const = s;
serial_info.size = serialized_size; serial_info.size = len;
if (!core_unserialize(&serial_info)) if (!core_unserialize(&serial_info))
return false; return false;
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
rcheevos_set_serialized_data(NULL); rcheevos_set_serialized_data(NULL);
#endif #endif
@ -963,18 +962,17 @@ bool content_deserialize_state(
} }
else else
{ {
unsigned char* input = (unsigned char*)serialized_data; unsigned char* input = (unsigned char*)s;
switch (input[7]) /* version */ switch (input[7]) /* version */
{ {
case 1: case 1:
if (content_load_rastate1(input, serialized_size)) if (content_load_rastate1(input, len))
break; break;
/* fall-through intentional */ /* fall-through intentional */
default: default:
return false; return false;
} }
} }
return true; return true;
} }
@ -1158,7 +1156,7 @@ static void save_state_cb(retro_task_t *task,
* *
* Create a new task to save the content state. * Create a new task to save the content state.
**/ **/
static void task_push_save_state(const char *path, void *data, size_t size, bool autosave) static void task_push_save_state(const char *path, void *data, size_t len, bool autosave)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
retro_task_t *task = task_init(); retro_task_t *task = task_init();
@ -1170,11 +1168,11 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
strlcpy(state->path, path, sizeof(state->path)); strlcpy(state->path, path, sizeof(state->path));
state->data = data; state->data = data;
state->size = size; state->size = len;
/* Don't show OSD messages if we are auto-saving */ /* Don't show OSD messages if we are auto-saving */
if (autosave) if (autosave)
state->flags |= (SAVE_TASK_FLAG_AUTOSAVE | state->flags |= ( SAVE_TASK_FLAG_AUTOSAVE
SAVE_TASK_FLAG_MUTE); | SAVE_TASK_FLAG_MUTE);
if (settings->bools.savestate_thumbnail_enable) if (settings->bools.savestate_thumbnail_enable)
{ {
/* Delay OSD messages and widgets for a few frames /* Delay OSD messages and widgets for a few frames
@ -1264,7 +1262,7 @@ static void content_load_and_save_state_cb(retro_task_t *task,
* and then save the content state. * and then save the content state.
**/ **/
static void task_push_load_and_save_state(const char *path, void *data, static void task_push_load_and_save_state(const char *path, void *data,
size_t size, bool load_to_backup_buffer, bool autosave) size_t len, bool load_to_backup_buffer, bool autosave)
{ {
retro_task_t *task = NULL; retro_task_t *task = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -1285,7 +1283,7 @@ static void task_push_load_and_save_state(const char *path, void *data,
strlcpy(state->path, path, sizeof(state->path)); strlcpy(state->path, path, sizeof(state->path));
if (load_to_backup_buffer) if (load_to_backup_buffer)
state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF; state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF;
state->undo_size = size; state->undo_size = len;
state->undo_data = data; state->undo_data = data;
/* Don't show OSD messages if we are auto-saving */ /* Don't show OSD messages if we are auto-saving */
if (autosave) if (autosave)
@ -1337,9 +1335,9 @@ static void task_push_load_and_save_state(const char *path, void *data,
**/ **/
bool content_auto_save_state(const char *path) bool content_auto_save_state(const char *path)
{ {
size_t _len;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
void *serial_data = NULL; void *serial_data = NULL;
size_t serial_size;
intfstream_t *file = NULL; intfstream_t *file = NULL;
if (!core_info_current_supports_savestate()) if (!core_info_current_supports_savestate())
@ -1349,12 +1347,11 @@ bool content_auto_save_state(const char *path)
return false; return false;
} }
serial_size = core_serialize_size(); _len = core_serialize_size();
if (_len == 0)
if (serial_size == 0)
return false; return false;
serial_data = content_get_serialized_data(&serial_size); serial_data = content_get_serialized_data(&_len);
if (!serial_data) if (!serial_data)
return false; return false;
@ -1372,7 +1369,7 @@ bool content_auto_save_state(const char *path)
return false; return false;
} }
if (serial_size != (size_t)intfstream_write(file, serial_data, serial_size)) if (_len != (size_t)intfstream_write(file, serial_data, _len))
{ {
intfstream_close(file); intfstream_close(file);
free(serial_data); free(serial_data);
@ -1395,7 +1392,6 @@ bool content_auto_save_state(const char *path)
take_screenshot(dir_screenshot, path, true, validfb, false, false); take_screenshot(dir_screenshot, path, true, validfb, false, false);
} }
#endif #endif
return true; return true;
} }
@ -1410,7 +1406,7 @@ bool content_auto_save_state(const char *path)
**/ **/
bool content_save_state(const char *path, bool save_to_disk) bool content_save_state(const char *path, bool save_to_disk)
{ {
size_t serial_size; size_t _len;
void *data = NULL; void *data = NULL;
if (!core_info_current_supports_savestate()) if (!core_info_current_supports_savestate())
@ -1420,14 +1416,13 @@ bool content_save_state(const char *path, bool save_to_disk)
return false; return false;
} }
serial_size = core_serialize_size(); _len = core_serialize_size();
if (_len == 0)
if (serial_size == 0)
return false; return false;
if (!save_state_in_background) if (!save_state_in_background)
{ {
if (!(data = content_get_serialized_data(&serial_size))) if (!(data = content_get_serialized_data(&_len)))
{ {
RARCH_ERR("[State]: %s \"%s\".\n", RARCH_ERR("[State]: %s \"%s\".\n",
msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO),
@ -1438,7 +1433,7 @@ bool content_save_state(const char *path, bool save_to_disk)
RARCH_LOG("[State]: %s \"%s\", %u %s.\n", RARCH_LOG("[State]: %s \"%s\", %u %s.\n",
msg_hash_to_str(MSG_SAVING_STATE), msg_hash_to_str(MSG_SAVING_STATE),
path, path,
(unsigned)serial_size, (unsigned)_len,
msg_hash_to_str(MSG_BYTES)); msg_hash_to_str(MSG_BYTES));
} }
@ -1451,16 +1446,16 @@ bool content_save_state(const char *path, bool save_to_disk)
/* TODO/FIXME - Use msg_hash_to_str here */ /* TODO/FIXME - Use msg_hash_to_str here */
RARCH_LOG("[State]: %s ...\n", RARCH_LOG("[State]: %s ...\n",
msg_hash_to_str(MSG_FILE_ALREADY_EXISTS_SAVING_TO_BACKUP_BUFFER)); msg_hash_to_str(MSG_FILE_ALREADY_EXISTS_SAVING_TO_BACKUP_BUFFER));
task_push_load_and_save_state(path, data, serial_size, true, false); task_push_load_and_save_state(path, data, _len, true, false);
} }
else else
task_push_save_state(path, data, serial_size, false); task_push_save_state(path, data, _len, false);
} }
else else
{ {
if (!data) if (!data)
{ {
if (!(data = content_get_serialized_data(&serial_size))) if (!(data = content_get_serialized_data(&_len)))
{ {
RARCH_ERR("[State]: %s \"%s\".\n", RARCH_ERR("[State]: %s \"%s\".\n",
msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO),
@ -1479,15 +1474,15 @@ bool content_save_state(const char *path, bool save_to_disk)
undo_load_buf.data = NULL; undo_load_buf.data = NULL;
} }
if (!(undo_load_buf.data = malloc(serial_size))) if (!(undo_load_buf.data = malloc(_len)))
{ {
free(data); free(data);
return false; return false;
} }
memcpy(undo_load_buf.data, data, serial_size); memcpy(undo_load_buf.data, data, _len);
free(data); free(data);
undo_load_buf.size = serial_size; undo_load_buf.size = _len;
strlcpy(undo_load_buf.path, path, sizeof(undo_load_buf.path)); strlcpy(undo_load_buf.path, path, sizeof(undo_load_buf.path));
} }
@ -1735,8 +1730,8 @@ bool content_load_state_from_ram(void)
**/ **/
bool content_save_state_to_ram(void) bool content_save_state_to_ram(void)
{ {
size_t _len;
void *data = NULL; void *data = NULL;
size_t serial_size;
if (!core_info_current_supports_savestate()) if (!core_info_current_supports_savestate())
{ {
@ -1745,14 +1740,14 @@ bool content_save_state_to_ram(void)
return false; return false;
} }
serial_size = core_serialize_size(); _len = core_serialize_size();
if (serial_size == 0) if (_len == 0)
return false; return false;
if (!save_state_in_background) if (!save_state_in_background)
{ {
if (!(data = content_get_serialized_data(&serial_size))) if (!(data = content_get_serialized_data(&_len)))
{ {
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));
@ -1761,13 +1756,13 @@ bool content_save_state_to_ram(void)
RARCH_LOG("[State]: %s, %u %s.\n", RARCH_LOG("[State]: %s, %u %s.\n",
msg_hash_to_str(MSG_SAVING_STATE), msg_hash_to_str(MSG_SAVING_STATE),
(unsigned)serial_size, (unsigned)_len,
msg_hash_to_str(MSG_BYTES)); msg_hash_to_str(MSG_BYTES));
} }
if (!data) if (!data)
{ {
if (!(data = content_get_serialized_data(&serial_size))) if (!(data = content_get_serialized_data(&_len)))
{ {
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));
@ -1782,15 +1777,15 @@ bool content_save_state_to_ram(void)
ram_buf.state_buf.data = NULL; ram_buf.state_buf.data = NULL;
} }
if (!(ram_buf.state_buf.data = malloc(serial_size))) if (!(ram_buf.state_buf.data = malloc(_len)))
{ {
free(data); free(data);
return false; return false;
} }
memcpy(ram_buf.state_buf.data, data, serial_size); memcpy(ram_buf.state_buf.data, data, _len);
free(data); free(data);
ram_buf.state_buf.size = serial_size; ram_buf.state_buf.size = _len;
ram_buf.to_write_file = true; ram_buf.to_write_file = true;
return true; return true;

View File

@ -331,15 +331,15 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
#endif #endif
} }
void RARCH_LOG_BUFFER(uint8_t *data, size_t size) void RARCH_LOG_BUFFER(uint8_t *data, size_t len)
{ {
unsigned i, offset; unsigned i, offset;
int padding = size % 16; int padding = len % 16;
uint8_t buf[16] = {0}; uint8_t buf[16] = {0};
RARCH_LOG("== %d-byte buffer ==================\n", (int)size); RARCH_LOG("== %d-byte buffer ==================\n", (int)len);
for (i = 0, offset = 0; i < size; i++) for (i = 0, offset = 0; i < len; i++)
{ {
buf[offset] = data[i]; buf[offset] = data[i];
offset++; offset++;
@ -468,7 +468,9 @@ void rarch_log_file_init(
time_t cur_time = time(NULL); time_t cur_time = time(NULL);
rtime_localtime(&cur_time, &tm_); rtime_localtime(&cur_time, &tm_);
strftime(timestamped_log_file_name, sizeof(timestamped_log_file_name), "retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_); strftime(timestamped_log_file_name,
sizeof(timestamped_log_file_name),
"retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_);
} }
/* If nothing has changed, do nothing */ /* If nothing has changed, do nothing */
@ -506,10 +508,10 @@ void rarch_log_file_init(
if (last_slash) if (last_slash)
{ {
char tmp_buf[PATH_MAX_LENGTH] = {0}; char tmp_buf[PATH_MAX_LENGTH] = {0};
size_t path_length = last_slash + 1 - override_path; size_t _len = last_slash + 1 - override_path;
if ((path_length > 1) && (path_length < PATH_MAX_LENGTH)) if ((_len > 1) && (_len < PATH_MAX_LENGTH))
strlcpy(tmp_buf, override_path, path_length * sizeof(char)); strlcpy(tmp_buf, override_path, _len * sizeof(char));
strlcpy(log_directory, tmp_buf, sizeof(log_directory)); strlcpy(log_directory, tmp_buf, sizeof(log_directory));
} }

View File

@ -227,7 +227,7 @@ void logger_send_v(const char *__format, va_list args);
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap); void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap);
void RARCH_DBG(const char *fmt, ...); void RARCH_DBG(const char *fmt, ...);
void RARCH_LOG(const char *fmt, ...); void RARCH_LOG(const char *fmt, ...);
void RARCH_LOG_BUFFER(uint8_t *buffer, size_t size); void RARCH_LOG_BUFFER(uint8_t *buffer, size_t len);
void RARCH_LOG_OUTPUT(const char *msg, ...); void RARCH_LOG_OUTPUT(const char *msg, ...);
void RARCH_WARN(const char *fmt, ...); void RARCH_WARN(const char *fmt, ...);
void RARCH_ERR(const char *fmt, ...); void RARCH_ERR(const char *fmt, ...);