Skip to content

Commit 5e6a298

Browse files
committed
Replace some usage of strchr with memchr
1 parent 07388c5 commit 5e6a298

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

gfx/drivers/vulkan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,8 +1768,9 @@ static void vulkan_font_render_message(vk_t *vk,
17681768

17691769
for (;;)
17701770
{
1771-
const char *delim = strchr(msg, '\n');
1772-
size_t msg_len = delim ? (size_t)(delim - msg) : strlen(msg);
1771+
size_t _msg_len = strlen(msg);
1772+
const char *delim = memchr(msg, '\n', _msg_len + 1);
1773+
size_t msg_len = delim ? (size_t)(delim - msg) : _msg_len;
17731774

17741775
/* Draw the line */
17751776
vulkan_font_render_line(vk, font, glyph_q, msg, msg_len,

libretro-common/formats/json/rjson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ double rjson_get_double(rjson_t *json)
10111011
snprintf(test, sizeof(test), "%.1f", 0.0f);
10121012
json->decimal_sep = test[1];
10131013
}
1014-
if (json->decimal_sep != '.' && (p = strchr(str, '.')) != NULL)
1014+
if (json->decimal_sep != '.' && (p = memchr(str, '.', strlen(str) + 1)) != NULL)
10151015
{
10161016
double res;
10171017
*p = json->decimal_sep;

menu/menu_displaylist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int filebrowser_parse(
317317
default:
318318
/* if a core has / in its list of supported extensions, the core
319319
supports loading of directories on the host file system */
320-
if (exts && strchr(exts, '/'))
320+
if (exts && memchr(exts, '/', strlen(exts) + 1))
321321
menu_entries_prepend(info_list,
322322
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USE_THIS_DIRECTORY),
323323
msg_hash_to_str(MENU_ENUM_LABEL_USE_THIS_DIRECTORY),

0 commit comments

Comments
 (0)