diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 1f8e480d1f..77206c92c0 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -289,20 +289,20 @@ static void rcheevos_client_http_task_save_callback(retro_task_t* task, void rcheevos_client_http_load_response(const rc_api_request_t* request, rc_client_server_callback_t callback, void* callback_data) { - size_t size = 0; char* contents; - FILE* file = fopen(CHEEVOS_JSON_OVERRIDE, "rb"); + size_t _len = 0; + FILE* file = fopen(CHEEVOS_JSON_OVERRIDE, "rb"); fseek(file, 0, SEEK_END); - size = ftell(file); + _len = ftell(file); fseek(file, 0, SEEK_SET); - contents = (char*)malloc(size + 1); - fread((void*)contents, 1, size, file); + contents = (char*)malloc(_len + 1); + fread((void*)contents, 1, _len, file); fclose(file); - contents[size] = 0; - CHEEVOS_LOG(RCHEEVOS_TAG "Loaded game info. Read %u bytes to %s\n", size, CHEEVOS_JSON_OVERRIDE); + contents[_len] = 0; + CHEEVOS_LOG(RCHEEVOS_TAG "Loaded game info. Read %u bytes to %s\n", _len, CHEEVOS_JSON_OVERRIDE); callback(contents, 200, callback_data); } diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 4b02ceb298..5e1a8d8d19 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -277,9 +277,9 @@ static void vulkan_debug_mark_object(VkDevice device, } static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, - size_t size, struct vk_buffer_range *range) + size_t len, struct vk_buffer_range *range) { - VkDeviceSize next_offset = chain->offset + size; + VkDeviceSize next_offset = chain->offset + len; if (next_offset <= chain->current->buffer.size) { range->data = (uint8_t*)chain->current->buffer.mapped + chain->offset; @@ -287,24 +287,21 @@ static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, range->offset = chain->offset; chain->offset = (next_offset + chain->alignment - 1) & ~(chain->alignment - 1); - return true; } - return false; } static struct vk_buffer_node *vulkan_buffer_chain_alloc_node( const struct vulkan_context *context, - size_t size, VkBufferUsageFlags usage) + size_t len, VkBufferUsageFlags usage) { struct vk_buffer_node *node = (struct vk_buffer_node*) malloc(sizeof(*node)); if (!node) return NULL; - node->buffer = vulkan_create_buffer( - context, size, usage); + context, len, usage); node->next = NULL; return node; } @@ -1355,7 +1352,7 @@ static void vulkan_create_wait_fences(gfx_ctx_vulkan_data_t *vk) bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, struct vk_buffer_chain *chain, - size_t size, struct vk_buffer_range *range) + size_t len, struct vk_buffer_range *range) { if (!chain->head) { @@ -1367,7 +1364,7 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, chain->offset = 0; } - if (!vulkan_buffer_chain_suballoc(chain, size, range)) + if (!vulkan_buffer_chain_suballoc(chain, len, range)) { /* We've exhausted the current chain, traverse list until we * can find a block we can use. Usually, we just step once. */ @@ -1375,24 +1372,24 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, { chain->current = chain->current->next; chain->offset = 0; - if (vulkan_buffer_chain_suballoc(chain, size, range)) + if (vulkan_buffer_chain_suballoc(chain, len, range)) return true; } /* We have to allocate a new node, might allocate larger * buffer here than block_size in case we have * a very large allocation. */ - if (size < chain->block_size) - size = chain->block_size; + if (len < chain->block_size) + len = chain->block_size; if (!(chain->current->next = vulkan_buffer_chain_alloc_node( - context, size, chain->usage))) + context, len, chain->usage))) return false; chain->current = chain->current->next; chain->offset = 0; /* This cannot possibly fail. */ - retro_assert(vulkan_buffer_chain_suballoc(chain, size, range)); + retro_assert(vulkan_buffer_chain_suballoc(chain, len, range)); } return true; } @@ -1418,7 +1415,7 @@ void vulkan_debug_mark_memory(VkDevice device, VkDeviceMemory memory) struct vk_buffer vulkan_create_buffer( const struct vulkan_context *context, - size_t size, VkBufferUsageFlags usage) + size_t len, VkBufferUsageFlags usage) { struct vk_buffer buffer; VkMemoryRequirements mem_reqs; @@ -1428,7 +1425,7 @@ struct vk_buffer vulkan_create_buffer( info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; info.pNext = NULL; info.flags = 0; - info.size = size; + info.size = len; info.usage = usage; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; info.queueFamilyIndexCount = 0; @@ -1450,7 +1447,7 @@ struct vk_buffer vulkan_create_buffer( vulkan_debug_mark_memory(context->device, buffer.memory); vkBindBufferMemory(context->device, buffer.buffer, buffer.memory, 0); - buffer.size = size; + buffer.size = len; vkMapMemory(context->device, buffer.memory, 0, buffer.size, 0, &buffer.mapped); diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index b1ef070d00..c09f575213 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -73,7 +73,7 @@ class Buffer public: Buffer(VkDevice device, const VkPhysicalDeviceMemoryProperties &mem_props, - size_t size, VkBufferUsageFlags usage); + size_t len, VkBufferUsageFlags usage); ~Buffer(); size_t get_size() const { return size; } @@ -1532,8 +1532,8 @@ StaticTexture::~StaticTexture() Buffer::Buffer(VkDevice device, const VkPhysicalDeviceMemoryProperties &mem_props, - size_t size, VkBufferUsageFlags usage) : - device(device), size(size) + size_t len, VkBufferUsageFlags usage) : + device(device), size(len) { VkBufferCreateInfo info; VkMemoryRequirements mem_reqs; @@ -1542,7 +1542,7 @@ Buffer::Buffer(VkDevice device, info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; info.pNext = NULL; info.flags = 0; - info.size = size; + info.size = len; info.usage = usage; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; info.queueFamilyIndexCount = 0; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 339341a7e7..7451f103c4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -198,18 +198,15 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { 4.0f / 3.0f , "" } /* full - initialized in video_driver_init_internal */ }; -static INLINE bool realloc_checked(void **ptr, size_t size) +static INLINE bool realloc_checked(void **ptr, size_t len) { void *nptr = NULL; - if (*ptr) - nptr = realloc(*ptr, size); + nptr = realloc(*ptr, len); else - nptr = malloc(size); - + nptr = malloc(len); if (nptr) *ptr = nptr; - return *ptr == nptr; } diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index b4322e66d4..b54191bae1 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -164,20 +164,20 @@ static void retrode_update_button_state(retrode_pad_data_t *pad) pad->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } -static void hidpad_retrode_pad_packet_handler(retrode_pad_data_t *pad, uint8_t *packet, size_t size) +static void hidpad_retrode_pad_packet_handler(retrode_pad_data_t *pad, uint8_t *packet, size_t len) { - memcpy(pad->data, packet, size); + memcpy(pad->data, packet, len); retrode_update_button_state(pad); } -static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, uint16_t size) +static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, uint16_t len) { retrode_device_data_t *device = (retrode_device_data_t *)device_data; if (!device) return; - memcpy(device->data, packet, size); + memcpy(device->data, packet, len); /* * packet[0] contains Retrode port number diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index c06ecfb37b..8e3422ec4a 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -191,17 +191,16 @@ static void update_analog_state(gca_pad_data_t *pad) } } -static void hidpad_wiiugca_pad_packet_handler(gca_pad_data_t *pad, uint8_t *packet, size_t size) +static void hidpad_wiiugca_pad_packet_handler(gca_pad_data_t *pad, uint8_t *packet, size_t len) { - if (size > 9) + if (len > 9) return; - - memcpy(pad->data, packet, size); + memcpy(pad->data, packet, len); update_button_state(pad); update_analog_state(pad); } -static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, uint16_t size) +static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, uint16_t len) { uint32_t i; gca_device_data_t *device = (gca_device_data_t *)device_data; @@ -209,7 +208,7 @@ static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, ui if (!device) return; - memcpy(device->data, packet, size); + memcpy(device->data, packet, len); for (i = 1; i < 37; i += 9) { diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 1a71d2edf0..83e77136d8 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -221,7 +221,7 @@ const struct input_key_map input_config_key_map[] = { { "media", RETROK_LAUNCH_MEDIA }, { "app1", RETROK_LAUNCH_APP1 }, { "app2", RETROK_LAUNCH_APP2 }, - + { "nul", RETROK_UNKNOWN }, { NULL, RETROK_UNKNOWN }, }; @@ -1189,7 +1189,7 @@ const struct rarch_key_map rarch_key_map_x11[] = { { XFVK_KP0, RETROK_KP0 }, { XFVK_KPDL, RETROK_KP_PERIOD }, { XFVK_KPEQ, RETROK_KP_EQUALS }, - + { XFVK_MUTE, RETROK_VOLUME_MUTE }, { XFVK_VOUP, RETROK_VOLUME_UP }, { XFVK_VODN, RETROK_VOLUME_DOWN }, @@ -1914,7 +1914,7 @@ const struct rarch_key_map rarch_key_map_ps3[] = { { KB_RAWKEY_SCROLL_LOCK, RETROK_SCROLLOCK }, { KB_RAWKEY_PAUSE, RETROK_BREAK }, - /* + /* { KB_RAWKEY_HASHTILDE, RETROK_HASH }, { KB_RAWKEY_KPLEFTPAREN, RETROK_LEFTPAREN }, { KB_RAWKEY_KPRIGHTPAREN, RETROK_RIGHTPAREN }, @@ -2162,7 +2162,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym) * Translates a retro key identifier to a human-readable * identifier string. **/ -void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size) +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t len) { unsigned i; @@ -2180,7 +2180,7 @@ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t siz if (input_config_key_map[i].key != key) continue; - strlcpy(buf, input_config_key_map[i].str, size); + strlcpy(buf, input_config_key_map[i].str, len); break; } } diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 2ffee2b67f..473a708d3a 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -224,12 +224,12 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); * input_keymaps_translate_rk_to_str: * @key : Retro key identifier. * @buf : Buffer. - * @size : Size of @buf. + * @len : Size of @buf. * * Translates a retro key identifier to a human-readable * identifier string. **/ -void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t len); /** * input_translate_rk_to_ascii: diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index 289ec25f1c..ef9f96b9de 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -62,11 +62,11 @@ struct sevenzip_context_t uint32_t block_index; }; -static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t size) +static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t len) { - if (size == 0) + if (len == 0) return 0; - return malloc(size); + return malloc(len); } static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address) @@ -77,12 +77,12 @@ static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address) free(address); } -static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t size) +static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t len) { (void)p; - if (size == 0) + if (len == 0) return 0; - return malloc(size); + return malloc(len); } static void* sevenzip_stream_new(void) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index f2edb10408..8f1ab25238 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1168,24 +1168,24 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len) } bool config_get_array(config_file_t *conf, const char *key, - char *buf, size_t size) + char *buf, size_t len) { const struct config_entry_list *entry = config_get_entry(conf, key); if (entry) - return strlcpy(buf, entry->value, size) < size; + return strlcpy(buf, entry->value, len) < len; return false; } bool config_get_path(config_file_t *conf, const char *key, - char *buf, size_t size) + char *buf, size_t len) { #if defined(RARCH_CONSOLE) || !defined(RARCH_INTERNAL) - return config_get_array(conf, key, buf, size); + return config_get_array(conf, key, buf, len); #else const struct config_entry_list *entry = config_get_entry(conf, key); if (entry) { - fill_pathname_expand_special(buf, entry->value, size); + fill_pathname_expand_special(buf, entry->value, len); return true; } return false; diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index ad484a4b84..a9a36b84c8 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -1170,7 +1170,7 @@ size_t fill_pathname_abbreviate_special(char *s, * * @returns new string that has been sanitized **/ -const char *sanitize_path_part(const char *path_part, size_t size) +const char *sanitize_path_part(const char *path_part, size_t len) { int i; int j = 0; @@ -1180,7 +1180,7 @@ const char *sanitize_path_part(const char *path_part, size_t size) if (string_is_empty(path_part)) return NULL; - tmp = (char *)malloc((size + 1) * sizeof(char)); + tmp = (char *)malloc((len + 1) * sizeof(char)); for (i = 0; path_part[i] != '\0'; i++) { diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index ced535cd23..97d5febd1a 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -49,10 +49,10 @@ static void dword_write_be(uint8_t *buf, uint32_t val) *buf++ = (uint8_t)(val >> 0); } -static bool png_write_crc_string(intfstream_t *intf_s, const uint8_t *data, size_t size) +static bool png_write_crc_string(intfstream_t *intf_s, const uint8_t *data, size_t len) { uint8_t crc_raw[4] = {0}; - uint32_t crc = encoding_crc32(0, data, size); + uint32_t crc = encoding_crc32(0, data, len); dword_write_be(crc_raw, crc); return intfstream_write(intf_s, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw); @@ -94,12 +94,11 @@ static bool png_write_ihdr_string(intfstream_t *intf_s, const struct png_ihdr *i sizeof(ihdr_raw) - sizeof(uint32_t)); } -static bool png_write_idat_string(intfstream_t* intf_s, const uint8_t *data, size_t size) +static bool png_write_idat_string(intfstream_t* intf_s, const uint8_t *data, size_t len) { - if (intfstream_write(intf_s, data, size) != (ssize_t)size) + if (intfstream_write(intf_s, data, len) != (ssize_t)len) return false; - - return png_write_crc_string(intf_s, data + sizeof(uint32_t), size - sizeof(uint32_t)); + return png_write_crc_string(intf_s, data + sizeof(uint32_t), len - sizeof(uint32_t)); } static bool png_write_iend_string(intfstream_t* intf_s) @@ -140,11 +139,11 @@ static void copy_bgr24_line(uint8_t *dst, const uint8_t *src, unsigned width) } } -static unsigned count_sad(const uint8_t *data, size_t size) +static unsigned count_sad(const uint8_t *data, size_t len) { size_t i; unsigned cnt = 0; - for (i = 0; i < size; i++) + for (i = 0; i < len; i++) { if (data[i]) cnt += abs((int8_t)data[i]); @@ -223,7 +222,7 @@ bool rpng_save_image_stream(const uint8_t *data, intfstream_t* intf_s, void *stream = NULL; uint32_t total_in = 0; uint32_t total_out = 0; - + if (!intf_s) GOTO_END_ERROR(); @@ -370,8 +369,8 @@ bool rpng_save_image_argb(const char *path, const uint32_t *data, { bool ret = false; intfstream_t* intf_s = NULL; - - intf_s = intfstream_open_file(path, + + intf_s = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); @@ -388,11 +387,11 @@ bool rpng_save_image_bgr24(const char *path, const uint8_t *data, { bool ret = false; intfstream_t* intf_s = NULL; - - intf_s = intfstream_open_file(path, + + intf_s = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); - ret = rpng_save_image_stream(data, intf_s, width, height, + ret = rpng_save_image_stream(data, intf_s, width, height, (signed) pitch, 3); intfstream_close(intf_s); free(intf_s); @@ -412,14 +411,14 @@ uint8_t* rpng_save_image_bgr24_string(const uint8_t *data, buf_length = (int)(width*height*3*DEFLATE_PADDING)+PNG_ROUGH_HEADER; buf = (uint8_t*)malloc(buf_length*sizeof(uint8_t)); if (!buf) - GOTO_END_ERROR(); + GOTO_END_ERROR(); - intf_s = intfstream_open_writable_memory(buf, + intf_s = intfstream_open_writable_memory(buf, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE, buf_length); - ret = rpng_save_image_stream((const uint8_t*)data, + ret = rpng_save_image_stream((const uint8_t*)data, intf_s, width, height, pitch, 3); *bytes = intfstream_get_ptr(intf_s); diff --git a/libretro-common/memmap/memalign.c b/libretro-common/memmap/memalign.c index 14eaeffdbd..d798d371b2 100644 --- a/libretro-common/memmap/memalign.c +++ b/libretro-common/memmap/memalign.c @@ -25,19 +25,17 @@ #include -void *memalign_alloc(size_t boundary, size_t size) +void *memalign_alloc(size_t boundary, size_t len) { void **place = NULL; uintptr_t addr = 0; - void *ptr = (void*)malloc(boundary + size + sizeof(uintptr_t)); + void *ptr = (void*)malloc(boundary + len + sizeof(uintptr_t)); if (!ptr) return NULL; - addr = ((uintptr_t)ptr + sizeof(uintptr_t) + boundary) & ~(boundary - 1); place = (void**)addr; place[-1] = ptr; - return (void*)addr; } @@ -51,13 +49,13 @@ void memalign_free(void *ptr) free(p[-1]); } -void *memalign_alloc_aligned(size_t size) +void *memalign_alloc_aligned(size_t len) { #if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || defined(_M_X64) || defined(_M_X64) || defined(_WIN64) - return memalign_alloc(64, size); + return memalign_alloc(64, len); #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(GEKKO) || defined(_M_IX86) - return memalign_alloc(32, size); + return memalign_alloc(32, len); #else - return memalign_alloc(32, size); + return memalign_alloc(32, len); #endif } diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 039a0b670e..ea5c936a9e 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -92,27 +92,24 @@ int socket_next(void **address) } ssize_t socket_receive_all_nonblocking(int fd, bool *error, - void *data_, size_t size) + void *data_, size_t len) { - ssize_t ret = recv(fd, (char*)data_, size, 0); - + ssize_t ret = recv(fd, (char*)data_, len, 0); if (ret > 0) return ret; - if (ret < 0 && isagain((int)ret)) return 0; - *error = true; return -1; } -bool socket_receive_all_blocking(int fd, void *data_, size_t size) +bool socket_receive_all_blocking(int fd, void *data_, size_t len) { const uint8_t *data = (const uint8_t*)data_; - while (size) + while (len) { - ssize_t ret = recv(fd, (char*)data, size, 0); + ssize_t ret = recv(fd, (char*)data, len, 0); if (!ret) return false; @@ -125,7 +122,7 @@ bool socket_receive_all_blocking(int fd, void *data_, size_t size) else { data += ret; - size -= ret; + len -= ret; } } @@ -133,8 +130,7 @@ bool socket_receive_all_blocking(int fd, void *data_, size_t size) } bool socket_receive_all_blocking_with_timeout(int fd, - void *data_, size_t size, - int timeout) + void *data_, size_t len, int timeout) { const uint8_t *data = (const uint8_t*)data_; retro_time_t deadline = cpu_features_get_time_usec(); @@ -144,9 +140,9 @@ bool socket_receive_all_blocking_with_timeout(int fd, else deadline += 5000000; - while (size) + while (len) { - ssize_t ret = recv(fd, (char*)data, size, 0); + ssize_t ret = recv(fd, (char*)data, len, 0); if (!ret) return false; @@ -169,7 +165,7 @@ bool socket_receive_all_blocking_with_timeout(int fd, else { data += ret; - size -= ret; + len -= ret; } } @@ -570,15 +566,15 @@ bool socket_wait(int fd, bool *rd, bool *wr, int timeout) #endif } -bool socket_send_all_blocking(int fd, const void *data_, size_t size, +bool socket_send_all_blocking(int fd, const void *data_, size_t len, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; int flags = no_signal ? MSG_NOSIGNAL : 0; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) continue; @@ -591,7 +587,7 @@ bool socket_send_all_blocking(int fd, const void *data_, size_t size, else { data += ret; - size -= ret; + len -= ret; } } @@ -599,7 +595,7 @@ bool socket_send_all_blocking(int fd, const void *data_, size_t size, } bool socket_send_all_blocking_with_timeout(int fd, - const void *data_, size_t size, + const void *data_, size_t len, int timeout, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; @@ -611,9 +607,9 @@ bool socket_send_all_blocking_with_timeout(int fd, else deadline += 5000000; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) continue; @@ -636,22 +632,22 @@ bool socket_send_all_blocking_with_timeout(int fd, else { data += ret; - size -= ret; + len -= ret; } } return true; } -ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size, +ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t len, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; int flags = no_signal ? MSG_NOSIGNAL : 0; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) break; @@ -666,7 +662,7 @@ ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size, else { data += ret; - size -= ret; + len -= ret; } } diff --git a/libretro-common/queues/fifo_queue.c b/libretro-common/queues/fifo_queue.c index 05deb18785..19543a81b9 100644 --- a/libretro-common/queues/fifo_queue.c +++ b/libretro-common/queues/fifo_queue.c @@ -29,24 +29,24 @@ #include -static bool fifo_initialize_internal(fifo_buffer_t *buf, size_t size) +static bool fifo_initialize_internal(fifo_buffer_t *buf, size_t len) { - uint8_t *buffer = (uint8_t*)calloc(1, size + 1); + uint8_t *buffer = (uint8_t*)calloc(1, len + 1); if (!buffer) return false; buf->buffer = buffer; - buf->size = size + 1; + buf->size = len + 1; buf->first = 0; buf->end = 0; return true; } -bool fifo_initialize(fifo_buffer_t *buf, size_t size) +bool fifo_initialize(fifo_buffer_t *buf, size_t len) { - return (buf && fifo_initialize_internal(buf, size)); + return (buf && fifo_initialize_internal(buf, len)); } void fifo_free(fifo_buffer_t *buffer) @@ -73,14 +73,14 @@ bool fifo_deinitialize(fifo_buffer_t *buffer) return true; } -fifo_buffer_t *fifo_new(size_t size) +fifo_buffer_t *fifo_new(size_t len) { fifo_buffer_t *buf = (fifo_buffer_t*)malloc(sizeof(*buf)); if (!buf) return NULL; - if (!fifo_initialize_internal(buf, size)) + if (!fifo_initialize_internal(buf, len)) { free(buf); return NULL; @@ -89,36 +89,36 @@ fifo_buffer_t *fifo_new(size_t size) return buf; } -void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size) +void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t len) { - size_t first_write = size; + size_t first_write = len; size_t rest_write = 0; - if (buffer->end + size > buffer->size) + if (buffer->end + len > buffer->size) { first_write = buffer->size - buffer->end; - rest_write = size - first_write; + rest_write = len - first_write; } memcpy(buffer->buffer + buffer->end, in_buf, first_write); memcpy(buffer->buffer, (const uint8_t*)in_buf + first_write, rest_write); - buffer->end = (buffer->end + size) % buffer->size; + buffer->end = (buffer->end + len) % buffer->size; } -void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size) +void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t len) { - size_t first_read = size; + size_t first_read = len; size_t rest_read = 0; - if (buffer->first + size > buffer->size) + if (buffer->first + len > buffer->size) { first_read = buffer->size - buffer->first; - rest_read = size - first_read; + rest_read = len - first_read; } memcpy(in_buf, (const uint8_t*)buffer->buffer + buffer->first, first_read); memcpy((uint8_t*)in_buf + first_read, buffer->buffer, rest_read); - buffer->first = (buffer->first + size) % buffer->size; + buffer->first = (buffer->first + len) % buffer->size; } diff --git a/libretro-common/queues/message_queue.c b/libretro-common/queues/message_queue.c index 4e7dea061c..d4b5c86098 100644 --- a/libretro-common/queues/message_queue.c +++ b/libretro-common/queues/message_queue.c @@ -28,7 +28,7 @@ #include #include -bool msg_queue_initialize(msg_queue_t *queue, size_t size) +bool msg_queue_initialize(msg_queue_t *queue, size_t len) { struct queue_elem **elems = NULL; @@ -36,31 +36,31 @@ bool msg_queue_initialize(msg_queue_t *queue, size_t size) return false; if (!(elems = (struct queue_elem**) - calloc(size + 1, sizeof(struct queue_elem*)))) + calloc(len + 1, sizeof(struct queue_elem*)))) return false; queue->tmp_msg = NULL; queue->elems = elems; queue->ptr = 1; - queue->size = size + 1; + queue->size = len + 1; return true; } /** * msg_queue_new: - * @size : maximum size of message + * @len : maximum size of message * * Creates a message queue with maximum size different messages. * * Returns: NULL if allocation error, pointer to a message queue * if successful. Has to be freed manually. **/ -msg_queue_t *msg_queue_new(size_t size) +msg_queue_t *msg_queue_new(size_t len) { msg_queue_t *queue = (msg_queue_t*)malloc(sizeof(*queue)); - if (!msg_queue_initialize(queue, size)) + if (!msg_queue_initialize(queue, len)) { if (queue) free(queue); diff --git a/libretro-common/streams/network_stream.c b/libretro-common/streams/network_stream.c index 47f426b942..48af03a10b 100644 --- a/libretro-common/streams/network_stream.c +++ b/libretro-common/streams/network_stream.c @@ -27,19 +27,19 @@ #include -bool netstream_open(netstream_t *stream, void *buf, size_t size, size_t used) +bool netstream_open(netstream_t *stream, void *buf, size_t len, size_t used) { if (buf) { /* Pre-allocated buffer must have a non-zero size. */ - if (!size || used > size) + if (!len || used > len) return false; } else { - if (size) + if (len) { - buf = malloc(size); + buf = malloc(len); if (!buf) return false; } @@ -48,7 +48,7 @@ bool netstream_open(netstream_t *stream, void *buf, size_t size, size_t used) } stream->buf = buf; - stream->size = size; + stream->size = len; stream->used = used; stream->pos = 0; @@ -252,14 +252,14 @@ bool netstream_write(netstream_t *stream, const void *data, size_t len) } else { - size_t size = stream->size + (len - remaining); - void *buf = realloc(stream->buf, size); + size_t _len = stream->size + (len - remaining); + void *buf = realloc(stream->buf, _len); if (!buf) return false; stream->buf = buf; - stream->size = size; + stream->size = _len; } } diff --git a/libretro-db/query.c b/libretro-db/query.c index 7fcf86bdf1..f8b861d463 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -347,13 +347,12 @@ static struct buffer query_expect_eof(char *s, size_t len, } static int query_peek(struct buffer buff, const char * data, - size_t size_data) + size_t len) { size_t remain = buff.len - buff.offset; - if (remain < size_data) + if (remain < len) return 0; - return (strncmp(buff.data + buff.offset, - data, size_data) == 0); + return (strncmp(buff.data + buff.offset, data, len) == 0); } static struct buffer query_get_char( diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 254bc73bbe..e05cba034d 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -458,9 +458,9 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, if (entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD) { size_t j; - size_t size = strlcpy(entry->password_value, entry->value, + size_t _len = strlcpy(entry->password_value, entry->value, sizeof(entry->password_value)); - for (j = 0; j < size; j++) + for (j = 0; j < _len; j++) entry->password_value[j] = '*'; } } diff --git a/menu/menu_explore.c b/menu/menu_explore.c index a10f6c51fa..90c10851de 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -183,23 +183,21 @@ static explore_state_t* explore_state; static void ex_arena_grow(ex_arena *arena, size_t min_size) { - size_t size = EX_ARENA_ALIGN_UP( + size_t _len = EX_ARENA_ALIGN_UP( MAX(min_size, EX_ARENA_BLOCK_SIZE), EX_ARENA_ALIGNMENT); - arena->ptr = (char *)malloc(size); - arena->end = arena->ptr + size; + arena->ptr = (char *)malloc(_len); + arena->end = arena->ptr + _len; RBUF_PUSH(arena->blocks, arena->ptr); } -static void *ex_arena_alloc(ex_arena *arena, size_t size) +static void *ex_arena_alloc(ex_arena *arena, size_t len) { void *ptr = NULL; - - if (size > (size_t)(arena->end - arena->ptr)) - ex_arena_grow(arena, size); - + if (len > (size_t)(arena->end - arena->ptr)) + ex_arena_grow(arena, len); ptr = arena->ptr; arena->ptr = (char *) - EX_ARENA_ALIGN_UP((uintptr_t)(arena->ptr + size), EX_ARENA_ALIGNMENT); + EX_ARENA_ALIGN_UP((uintptr_t)(arena->ptr + len), EX_ARENA_ALIGNMENT); return ptr; } @@ -996,14 +994,14 @@ static const char* explore_get_view_path(struct menu_state *menu_st, menu_list_t const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx; if (driver_ctx->list_get_entry) { - size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; - size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; - if (selection > 0 && size > 0) + size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; + size_t _len = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; + if (selection > 0 && _len > 0) { struct item_file *item = NULL; /* Label contains the path and path contains the label */ if ((item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL, - (unsigned)(selection - (size +1))))) + (unsigned)(selection - (_len +1))))) return item->label; } } diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index cd99527d52..d44526f885 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -735,12 +735,12 @@ static void RETRO_CALLCONV netplay_netpacket_poll_receive_cb(void); * * Initialize a new socket buffer. */ -static bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t size) +static bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t len) { - sbuf->data = (unsigned char*)malloc(size); + sbuf->data = (unsigned char*)malloc(len); if (!sbuf->data) return false; - sbuf->bufsz = size; + sbuf->bufsz = len; sbuf->start = sbuf->read = sbuf->end = 0; return true; @@ -2197,7 +2197,7 @@ static void netplay_delta_frame_free(struct delta_frame *delta) */ static netplay_input_state_t netplay_input_state_for( netplay_input_state_t *list, - uint32_t client_num, size_t size, + uint32_t client_num, size_t len, bool must_create, bool must_not_create) { netplay_input_state_t ret; @@ -2206,16 +2206,16 @@ static netplay_input_state_t netplay_input_state_for( while (*list) { ret = *list; - if (!ret->used && !must_not_create && ret->size == size) + if (!ret->used && !must_not_create && ret->size == len) { ret->client_num = client_num; ret->used = true; - memset(ret->data, 0, size*sizeof(uint32_t)); + memset(ret->data, 0, len * sizeof(uint32_t)); return ret; } else if (ret->used && ret->client_num == client_num) { - if (!must_create && ret->size == size) + if (!must_create && ret->size == len) return ret; return NULL; } @@ -2226,8 +2226,8 @@ static netplay_input_state_t netplay_input_state_for( return NULL; /* Couldn't find a slot, allocate a fresh one */ - if (size > 1) - ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); + if (len > 1) + ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (len - 1) * sizeof(uint32_t)); else ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state)); if (!ret) @@ -2235,7 +2235,7 @@ static netplay_input_state_t netplay_input_state_for( *list = ret; ret->client_num = client_num; ret->used = true; - ret->size = (uint32_t)size; + ret->size = (uint32_t)len; return ret; } @@ -4477,21 +4477,19 @@ bool netplay_send_cur_input(netplay_t *netplay, */ bool netplay_send_raw_cmd(netplay_t *netplay, struct netplay_connection *connection, uint32_t cmd, const void *data, - size_t size) + size_t len) { uint32_t cmdbuf[2]; cmdbuf[0] = htonl(cmd); - cmdbuf[1] = htonl(size); + cmdbuf[1] = htonl(len); if (!netplay_send(&connection->send_packet_buffer, connection->fd, cmdbuf, sizeof(cmdbuf))) return false; - - if (size > 0) - if (!netplay_send(&connection->send_packet_buffer, connection->fd, data, size)) + if (len > 0) + if (!netplay_send(&connection->send_packet_buffer, connection->fd, data, len)) return false; - return true; } @@ -4503,7 +4501,7 @@ bool netplay_send_raw_cmd(netplay_t *netplay, */ void netplay_send_raw_cmd_all(netplay_t *netplay, struct netplay_connection *except, uint32_t cmd, const void *data, - size_t size) + size_t len) { size_t i; for (i = 0; i < netplay->connections_size; i++) @@ -4514,7 +4512,7 @@ void netplay_send_raw_cmd_all(netplay_t *netplay, if ( (connection->flags & NETPLAY_CONN_FLAG_ACTIVE) && (connection->mode >= NETPLAY_CONNECTION_CONNECTED)) { - if (!netplay_send_raw_cmd(netplay, connection, cmd, data, size)) + if (!netplay_send_raw_cmd(netplay, connection, cmd, data, len)) netplay_hangup(netplay, connection); } } @@ -7054,13 +7052,13 @@ static bool netplay_init_socket_buffers(netplay_t *netplay) return true; } -static void netplay_write_block_header(unsigned char* output, const char* header, size_t size) +static void netplay_write_block_header(unsigned char* output, const char* header, size_t len) { memcpy(output, header, 4); - output[4] = ((size) & 0xFF); - output[5] = ((size >> 8) & 0xFF); - output[6] = ((size >> 16) & 0xFF); - output[7] = ((size >> 24) & 0xFF); + output[4] = ((len) & 0xFF); + output[5] = ((len >> 8) & 0xFF); + output[6] = ((len >> 16) & 0xFF); + output[7] = ((len >> 24) & 0xFF); } static bool netplay_init_serialization(netplay_t *netplay) diff --git a/runahead.c b/runahead.c index 12147a3145..0f26be6632 100644 --- a/runahead.c +++ b/runahead.c @@ -533,15 +533,14 @@ bool secondary_core_ensure_exists(void *data, settings_t *settings) #if defined(HAVE_DYNAMIC) static bool secondary_core_deserialize(runloop_state_t *runloop_st, - settings_t *settings, - const void *data, size_t size) + settings_t *settings, const void *data, size_t len) { bool ret = false; if (secondary_core_ensure_exists(runloop_st, settings)) { runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE; - ret = runloop_st->secondary_core.retro_unserialize(data, size); + ret = runloop_st->secondary_core.retro_unserialize(data, len); runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE; } else @@ -828,12 +827,12 @@ static void runahead_reset_hook(void) runloop_st->retro_reset_callback_original(); } -static bool runahead_unserialize_hook(const void *buf, size_t size) +static bool runahead_unserialize_hook(const void *buf, size_t len) { runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; if (runloop_st->retro_unserialize_callback_original) - return runloop_st->retro_unserialize_callback_original(buf, size); + return runloop_st->retro_unserialize_callback_original(buf, len); return false; } diff --git a/runloop.c b/runloop.c index 9a6dc93aec..1d5339c34e 100644 --- a/runloop.c +++ b/runloop.c @@ -558,7 +558,7 @@ void libretro_get_environment_info( } static dylib_t load_dynamic_core(const char *path, char *buf, - size_t size) + size_t len) { #if defined(ANDROID) /* Can't resolve symlinks when dealing with cores @@ -589,7 +589,7 @@ static dylib_t load_dynamic_core(const char *path, char *buf, /* Need to use absolute path for this setting. It can be * saved to content history, and a relative path would * break in that scenario. */ - path_resolve_realpath(buf, size, resolve_symlinks); + path_resolve_realpath(buf, len, resolve_symlinks); return dylib_load(path); } diff --git a/save.c b/save.c index f282369985..e3aef59eff 100644 --- a/save.c +++ b/save.c @@ -407,7 +407,7 @@ static bool content_load_ram_file(unsigned slot) * Attempt to save valuable RAM data somewhere. **/ static bool dump_to_file_desperate(const void *data, - size_t size, unsigned type) + size_t len, unsigned type) { char path[PATH_MAX_LENGTH + 256 + 32]; path [0] = '\0'; @@ -434,7 +434,7 @@ static bool dump_to_file_desperate(const void *data, * > In this case, we don't want to further * complicate matters by introducing zlib * compression overheads */ - if (filestream_write_file(path, data, size)) + if (filestream_write_file(path, data, len)) { RARCH_WARN("[SRAM]: Succeeded in saving RAM data to \"%s\".\n", path); return true; diff --git a/tasks/task_content.c b/tasks/task_content.c index 5c93ed43be..1d4512c627 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -407,7 +407,7 @@ static void content_file_list_free( free(file_list); } -static content_file_list_t *content_file_list_init(size_t size) +static content_file_list_t *content_file_list_init(size_t len) { content_file_list_t *file_list = NULL; @@ -424,17 +424,17 @@ static content_file_list_t *content_file_list_init(size_t size) { /* Create entries list */ if ((file_list->entries = (content_file_info_t *) - calloc(size, sizeof(content_file_info_t)))) + calloc(len, sizeof(content_file_info_t)))) { - file_list->size = size; + file_list->size = len; /* Create retro_game_info object */ if ((file_list->game_info = (struct retro_game_info *) - calloc(size, sizeof(struct retro_game_info)))) + calloc(len, sizeof(struct retro_game_info)))) { /* Create retro_game_info_ext object */ if ((file_list->game_info_ext = (struct retro_game_info_ext *) - calloc(size, sizeof(struct retro_game_info_ext)))) + calloc(len, sizeof(struct retro_game_info_ext)))) return file_list; } } diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index b369c1546e..321b9aea5b 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -517,24 +517,21 @@ end: } static ssize_t task_overlay_find_index(const struct overlay *ol, - const char *name, size_t size) + const char *name, size_t len) { size_t i; - if (!ol) return -1; - - for (i = 0; i < size; i++) + for (i = 0; i < len; i++) { if (string_is_equal(ol[i].name, name)) return i; } - return -1; } static bool task_overlay_resolve_targets(struct overlay *ol, - size_t idx, size_t size) + size_t idx, size_t len) { unsigned i; struct overlay *current = (struct overlay*)&ol[idx]; @@ -543,11 +540,11 @@ static bool task_overlay_resolve_targets(struct overlay *ol, { struct overlay_desc *desc = (struct overlay_desc*)¤t->descs[i]; const char *next = desc->next_index_name; - ssize_t next_idx = (idx + 1) % size; + ssize_t next_idx = (idx + 1) % len; if (!string_is_empty(next)) { - next_idx = task_overlay_find_index(ol, next, size); + next_idx = task_overlay_find_index(ol, next, len); if (next_idx < 0) {