Skip to content

Commit

Permalink
len variable/argument name standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 15, 2025
1 parent 076c2bc commit 9da7af4
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 132 deletions.
10 changes: 5 additions & 5 deletions gfx/common/d3dcompiler_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ HRESULT WINAPI
}
#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)
{
D3DBlob error_msg;
Expand All @@ -125,18 +125,18 @@ bool d3d_compile(const char* src, size_t size,
UINT compileflags = 0;
#endif

if (!size)
size = strlen(src);
if (!len)
len = strlen(src);

if (FAILED(D3DCompile(
src, size, src_name, NULL, NULL,
src, len, src_name, NULL, NULL,
entrypoint, target, compileflags, 0, out, &error_msg)))
{
if (error_msg)
{
const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg);
RARCH_ERR("D3DCompile failed :\n%s\n", msg);
/* Place a breakpoint here, if you want,
/* Place a breakpoint here, if you want,
to see shader compilation issues */
Release(error_msg);
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/common/d3dcompiler_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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);

bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out);
Expand Down
28 changes: 11 additions & 17 deletions input/drivers_hid/wiiu_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ static int16_t wiiu_hid_joypad_state(
const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE)
? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (
(uint16_t)joykey != NO_BTN
(uint16_t)joykey != NO_BTN
&& pad->iface->button && pad->iface->button(pad->connection, (uint16_t)joykey))
ret |= ( 1 << i);
else if (joyaxis != AXIS_NONE && pad->iface->get_axis &&
((float)abs(pad->iface->get_axis(pad->connection, joyaxis))
((float)abs(pad->iface->get_axis(pad->connection, joyaxis))
/ 0x8000) > joypad_info->axis_threshold)
ret |= (1 << i);
}
Expand All @@ -194,12 +194,11 @@ static bool wiiu_hid_joypad_rumble(void *data, unsigned slot,
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)
memset(result, 0, size);

memset(result, 0, len);
return result;
}

Expand Down Expand Up @@ -663,7 +662,7 @@ static uint8_t wiiu_hid_try_init_driver(wiiu_adapter_t *adapter)
adapter->device_name);

adapter->pad_driver = entry->iface;

if (entry->iface->multi_pad)
return wiiu_hid_try_init_driver_multi(adapter, entry);

Expand Down Expand Up @@ -749,7 +748,7 @@ static void wiiu_hid_poll(void *data)
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;
int32_t result;
Expand All @@ -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);
memcpy(adapter->tx_buffer, buf, size);
memcpy(adapter->tx_buffer, buf, len);

/* 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
Expand Down Expand Up @@ -848,24 +847,19 @@ static int32_t wiiu_hid_set_protocol(void *data, uint8_t protocol)
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;
int32_t result;

if (!adapter)
return -1;

if (size > adapter->rx_size)
if (len > adapter->rx_size)
return -1;

if ((result = HIDRead(adapter->handle, buffer, size, NULL, NULL)) < 0)
if ((result = HIDRead(adapter->handle, buffer, len, NULL, NULL)) < 0)
wiiu_hid_report_hid_error("read failed", adapter, result);

return result;
}


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;
Expand Down
4 changes: 2 additions & 2 deletions libretro-common/formats/json/rjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,14 +930,14 @@ static int _rjson_buffer_io(void* buf, int len, void *user)
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);
const char **ud = (const char **)(json + 1);
if (!json)
return NULL;
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));
return json;
}
Expand Down
2 changes: 1 addition & 1 deletion libretro-common/include/formats/rjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct RFILE;
/* Create a new parser instance from various sources */
rjson_t *rjson_open_stream(struct intfstream_internal *stream);
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_user(rjson_io_t io, void *user_data, int io_block_size);

Expand Down
26 changes: 9 additions & 17 deletions libretro-common/streams/stdin_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@
#include <streams/stdin_stream.h>

#if (defined(_WIN32) && defined(_XBOX)) || defined(__WINRT__) || !defined(__PSL1GHT__) && defined(__PS3__)
size_t read_stdin(char *buf, size_t size)
{
/* Not implemented. */
return 0;
}
size_t read_stdin(char *buf, size_t len) { return 0; } /* not implemented */
#elif defined(_WIN32)
size_t read_stdin(char *buf, size_t size)
size_t read_stdin(char *buf, size_t len)
{
DWORD i;
DWORD has_read = 0;
Expand Down Expand Up @@ -90,7 +86,7 @@ size_t read_stdin(char *buf, size_t size)
{
has_key = true;
echo = true;
avail = size;
avail = len;
break;
}
}
Expand All @@ -105,8 +101,8 @@ size_t read_stdin(char *buf, size_t size)
if (!avail)
return 0;

if (avail > size)
avail = size;
if (avail > len)
avail = len;

if (!ReadFile(hnd, buf, avail, &has_read, NULL))
return 0;
Expand All @@ -130,22 +126,18 @@ size_t read_stdin(char *buf, size_t size)
return has_read;
}
#else
size_t read_stdin(char *buf, size_t size)
size_t read_stdin(char *buf, size_t len)
{
size_t has_read = 0;

while (size)
while (len)
{
ssize_t ret = read(STDIN_FILENO, buf, size);

ssize_t ret = read(STDIN_FILENO, buf, len);
if (ret <= 0)
break;

buf += ret;
has_read += ret;
size -= ret;
len -= ret;
}

return has_read;
}
#endif
8 changes: 4 additions & 4 deletions libretro-common/streams/trans_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
* for the new stream data to be saved
* @in : input data
* @in_size : input size
* @out : output data
* @out_size : output size
* @s : output data
* @len : output size
* @error : (optional) output for error code
*
* Perform a full transcoding from a source to a destination.
*/
bool trans_stream_trans_full(
struct trans_stream_backend *backend, void **data,
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)
{
void *rdata;
Expand All @@ -57,7 +57,7 @@ bool trans_stream_trans_full(
}

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);

if (data)
Expand Down
8 changes: 4 additions & 4 deletions save.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void autosave_thread(void *data)
* autosave_new:
* @path : path to autosave file
* @data : pointer to buffer
* @size : size of @data buffer
* @len : size of @data buffer
* @interval : interval at which saves should be performed.
*
* Create and initialize autosave object.
Expand All @@ -161,7 +161,7 @@ static void autosave_thread(void *data)
* NULL.
**/
static autosave_t *autosave_new(const char *path,
const void *data, size_t size,
const void *data, size_t len,
unsigned interval, bool compress)
{
void *buf = NULL;
Expand All @@ -170,14 +170,14 @@ static autosave_t *autosave_new(const char *path,
return NULL;

handle->flags = 0;
handle->bufsize = size;
handle->bufsize = len;
handle->interval = interval;
if (compress)
handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES;
handle->retro_buffer = data;
handle->path = path;

if (!(buf = malloc(size)))
if (!(buf = malloc(len)))
{
free(handle);
return NULL;
Expand Down
32 changes: 15 additions & 17 deletions state_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t);
uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1);
size_t _len = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t);
uint16_t *ret = (uint16_t*)calloc(_len + sizeof(uint16_t) * 4 + 16, 1);

if (!ret)
return NULL;
Expand All @@ -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
* Valgrind happy is worth it. */
ret[len16/sizeof(uint16_t) + 3] = uniq;
ret[_len / sizeof(uint16_t) + 3] = uniq;

return ret;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ static size_t state_manager_raw_compress(const void *src,
continue;
}

changed = find_same(old16, new16);
changed = find_same(old16, new16);
if (changed > UINT16_MAX)
changed = UINT16_MAX;

Expand Down Expand Up @@ -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
* state_manager_raw_compress(), anything at all can happen.
*/
static void state_manager_raw_decompress(const void *patch,
size_t patchlen, void *data, size_t datalen)
static void state_manager_raw_decompress(const void *patch, void *data)
{
uint16_t *out16 = (uint16_t*)data;
const uint16_t *patch16 = (const uint16_t*)patch;
Expand Down Expand Up @@ -473,8 +472,7 @@ static bool state_manager_pop(state_manager_t *state, const void **data)
compressed = state->data + start + sizeof(size_t);
out = state->thisblock;

state_manager_raw_decompress(compressed,
state->maxcompsize, out, state->blocksize);
state_manager_raw_decompress(compressed, out);

state->entries--;
return true;
Expand Down Expand Up @@ -512,8 +510,8 @@ static void state_manager_push_do(state_manager_t *state)

if (state->thisblock_valid)
{
const uint8_t *oldb, *newb;
uint8_t *compressed;
const uint8_t *oldb, *newb;
size_t headpos, tailpos, remaining;
if (state->capacity < sizeof(size_t) + state->maxcompsize) {
RARCH_ERR("State capacity insufficient\n");
Expand Down Expand Up @@ -666,14 +664,14 @@ void state_manager_event_deinit(
free(rewind_st->state);
}

rewind_st->state = NULL;
rewind_st->size = 0;
rewind_st->flags &= ~(
STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED
| STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED
| STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED
| STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED
);
rewind_st->state = NULL;
rewind_st->size = 0;
rewind_st->flags &= ~(
STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED
| STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED
| STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED
| STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED
);

/* Restore regular (non-rewind) core audio
* callbacks if required */
Expand Down
Loading

0 comments on commit 9da7af4

Please sign in to comment.