From 046c2375e7b31c9968a5f0acc96c396086e37bfd Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 10 Sep 2024 07:03:10 +0200 Subject: [PATCH] Downsize big char arrays in shader structs - a lot of these get allocated on the stack so this would cost a lot of memory --- gfx/video_shader_parse.h | 4 ++-- libretro-common/include/retro_miscellaneous.h | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index c1ecb1778b..30f50151c7 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -178,7 +178,7 @@ struct video_shader_pass char *vertex; /* Dynamically allocated. Must be free'd. */ char *fragment; /* Dynamically allocated. Must be free'd. */ } string; - char path[PATH_MAX_LENGTH]; + char path[NAME_MAX_LENGTH*2]; } source; char alias[64]; uint8_t flags; @@ -189,7 +189,7 @@ struct video_shader_lut unsigned filter; enum gfx_wrap_type wrap; char id[64]; - char path[PATH_MAX_LENGTH]; + char path[NAME_MAX_LENGTH*2]; bool mipmap; }; diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 0ccc4e300a..24b18c938f 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -139,6 +139,14 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count) #define DIR_MAX_LENGTH 256 #endif +/** + * An upper limit for the length of a file or directory (excluding parent directories). + * If a path has a component longer than this, it may not work properly. + */ +#ifndef NAME_MAX_LENGTH +#define NAME_MAX_LENGTH 128 +#endif + #else #ifndef PATH_MAX_LENGTH @@ -149,8 +157,6 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count) #define DIR_MAX_LENGTH 1024 #endif -#endif - /** * An upper limit for the length of a file or directory (excluding parent directories). * If a path has a component longer than this, it may not work properly. @@ -159,6 +165,9 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count) #define NAME_MAX_LENGTH 256 #endif +#endif + + #ifndef MAX /** * @return \c a or \c b, whichever is larger.