(MaterialUI/Ozone) Prevent more unnecessary strlcats

This commit is contained in:
twinaphex 2019-09-18 06:43:01 +02:00
parent a9ef8333eb
commit f663c64cd4
2 changed files with 26 additions and 9 deletions

View File

@ -1121,6 +1121,7 @@ static void materialui_draw_bg(menu_display_ctx_draw_t *draw,
and the menu list */
static void materialui_frame(void *data, video_frame_info_t *video_info)
{
size_t copied;
/* This controls the main background color */
menu_display_ctx_clearcolor_t clearcolor;
@ -1599,12 +1600,14 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
/* Title */
usable_width = width - (mui->margin * 2) - title_margin;
strlcpy(menu_title, mui->menu_title, sizeof(menu_title));
copied = strlcpy(menu_title, mui->menu_title, sizeof(menu_title));
if (materialui_get_core_title(title_msg, sizeof(title_msg)) == 0)
{
strlcat(menu_title, " (", sizeof(menu_title));
strlcat(menu_title, title_msg, sizeof(menu_title));
strlcat(menu_title, ")", sizeof(menu_title));
string_add_space_fast(menu_title, copied);
string_add_pair_open_fast(menu_title, copied+1);
copied = strlcat(menu_title, title_msg, sizeof(menu_title));
string_add_pair_close_fast(menu_title, copied);
}
if (use_smooth_ticker)

View File

@ -574,15 +574,21 @@ static void ozone_context_reset(void *data, bool is_threaded)
/* Textures init */
for (i = 0; i < OZONE_TEXTURE_LAST; i++)
{
size_t copied;
char filename[PATH_MAX_LENGTH];
filename[0] = '\0';
#if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
copied = strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
else
#endif
strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
copied = strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
strlcat(filename, ".png", sizeof(filename));
string_add_dot_fast(filename, copied);
filename[copied+1] = 'p';
filename[copied+2] = 'n';
filename[copied+3] = 'g';
filename[copied+4] = '\0';
#if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
@ -610,9 +616,17 @@ static void ozone_context_reset(void *data, bool is_threaded)
/* Sidebar textures */
for (i = 0; i < OZONE_TAB_TEXTURE_LAST; i++)
{
size_t copied;
char filename[PATH_MAX_LENGTH];
strlcpy(filename, OZONE_TAB_TEXTURES_FILES[i], sizeof(filename));
strlcat(filename, ".png", sizeof(filename));
filename[0] = '\0';
copied = strlcpy(filename,
OZONE_TAB_TEXTURES_FILES[i], sizeof(filename));
string_add_dot_fast(filename, copied);
filename[copied+1] = 'p';
filename[copied+2] = 'n';
filename[copied+3] = 'g';
filename[copied+4] = '\0';
if (!menu_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
{