mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-07-10 13:29:52 -04:00
font.c glyph_cache_load() reduce stack
open the glyph cache in a separate function so we can get the MAX_PATH alloc off the stack quickly and deal with the fd instead Change-Id: I0e991a1286b29c781e3f03b6a49e100c70809920
This commit is contained in:
parent
e5c7f0c41c
commit
dfe965d81e
1 changed files with 9 additions and 13 deletions
|
|
@ -883,13 +883,14 @@ const unsigned char* font_get_bits(struct font* pf, ucschar_t char_code)
|
|||
return bits;
|
||||
}
|
||||
|
||||
static void font_path_to_glyph_path( const char *font_path, char *glyph_path)
|
||||
extern int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...); /*misc.c*/
|
||||
static NO_INLINE int font_path_open_glyphcache(const char *font_path, int oflags)
|
||||
{
|
||||
/* take full file name, cut extension, and add .glyphcache */
|
||||
strmemccpy(glyph_path, font_path, MAX_PATH);
|
||||
int dotidx = strlen(glyph_path) - sizeof(FONT_EXT);
|
||||
strmemccpy(glyph_path + dotidx, "." GLYPH_CACHE_EXT, MAX_PATH - dotidx);
|
||||
logf("%s %s", __func__, glyph_path);
|
||||
char glyph_path[MAX_PATH];
|
||||
int dotidx = strlen(font_path) - sizeof(FONT_EXT);
|
||||
logf("%s %.*s.%s", __func__, dotidx, font_path, GLYPH_CACHE_EXT);
|
||||
return open_pathfmt(glyph_path, sizeof(glyph_path), oflags,
|
||||
"%.*s.%s", dotidx, font_path, GLYPH_CACHE_EXT);
|
||||
}
|
||||
|
||||
/* call with NULL to flush */
|
||||
|
|
@ -944,9 +945,7 @@ static void glyph_cache_save(int font_id)
|
|||
|
||||
if(pf && pf->fd >= 0)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
font_path_to_glyph_path(pdata->path, filename);
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
fd = font_path_open_glyphcache(pdata->path, O_WRONLY|O_CREAT|O_TRUNC);
|
||||
if (fd >= 0)
|
||||
{
|
||||
uint32_t header = FC_HEADER_VAL;
|
||||
|
|
@ -987,10 +986,7 @@ static NO_INLINE void glyph_cache_load(const char *font_path, struct font *pf)
|
|||
if ( sort_size > MAX_SORT )
|
||||
sort_size = MAX_SORT;
|
||||
|
||||
char filename[MAX_PATH];
|
||||
font_path_to_glyph_path(font_path, filename);
|
||||
|
||||
fd = open(filename, O_RDONLY|O_BINARY);
|
||||
fd = font_path_open_glyphcache(font_path, O_RDONLY|O_BINARY);
|
||||
#ifdef TRY_DEFAULT_GLYPHCACHE
|
||||
/* if font specific file fails, try default */
|
||||
if (fd < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue