Skip to content

Commit

Permalink
Cutdown on some strlens
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jul 15, 2023
1 parent f39f1f6 commit 3c1e641
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
17 changes: 13 additions & 4 deletions gfx/common/win32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,7 @@ static void win32_localize_menu(HMENU menu)
if (label_enum != MSG_UNKNOWN)
{
int len;
size_t len2;
#ifndef LEGACY_WIN32
wchar_t* new_label_unicode = NULL;
#else
Expand All @@ -2104,18 +2105,26 @@ static void win32_localize_menu(HMENU menu)
Fullscreen = "Alt+Enter" */
if (label_enum ==
MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST)
meta_key_name = "Ctrl+O";
{
meta_key_name = "Ctrl+O";
len2 = STRLEN_CONST("Ctrl+O");
}
else if (label_enum ==
MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY)
meta_key_name = "Alt+Enter";
{
meta_key_name = "Alt+Enter";
len2 = STRLEN_CONST("Alt+Enter");
}
else if (meta_key != 0)
meta_key_name = meta_key_to_name(meta_key);
{
meta_key_name = meta_key_to_name(meta_key);
len2 = strlen(meta_key_name);
}

/* Append localized name, tab character, and Shortcut Key */
if (meta_key_name && string_is_not_equal(meta_key_name, "nul"))
{
size_t len1 = strlen(new_label);
size_t len2 = strlen(meta_key_name);
size_t buf_size = len1 + len2 + 2;
new_label_text = (char*)malloc(buf_size);

Expand Down
10 changes: 4 additions & 6 deletions menu/drivers/ozone.c
Original file line number Diff line number Diff line change
Expand Up @@ -4164,11 +4164,10 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
(ozone->dimensions.thumbnail_bar_width
- ((ozone->dimensions.sidebar_entry_icon_padding * 2) * 2))
/ ozone->fonts.footer.glyph_width;

strlcpy(tmpstr, ozone->selection_core_name, sizeof(tmpstr));
size_t _len = strlcpy(tmpstr, ozone->selection_core_name, sizeof(tmpstr));
(ozone->word_wrap)(ozone->selection_core_name,
sizeof(ozone->selection_core_name),
tmpstr, strlen(tmpstr),
tmpstr, _len,
metadata_len, ozone->fonts.footer.wideglyph_width, 0);
ozone->selection_core_name_lines = ozone_count_lines(ozone->selection_core_name);
}
Expand Down Expand Up @@ -4227,10 +4226,9 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
* (unlike core names), so this should never overflow the
* side bar */
char tmpstr[256];

strlcpy(tmpstr, ozone->selection_lastplayed, sizeof(tmpstr));
size_t _len = strlcpy(tmpstr, ozone->selection_lastplayed, sizeof(tmpstr));
(ozone->word_wrap)(ozone->selection_lastplayed,
sizeof(ozone->selection_lastplayed), tmpstr, strlen(tmpstr), 30, 100, 0);
sizeof(ozone->selection_lastplayed), tmpstr, _len, 30, 100, 0);
ozone->selection_lastplayed_lines = ozone_count_lines(ozone->selection_lastplayed);
}
else
Expand Down

0 comments on commit 3c1e641

Please sign in to comment.