From 205ef12b9d503c1fedd5534dab9a8f5fe49798f7 Mon Sep 17 00:00:00 2001 From: Fred Bauer Date: Thu, 29 Sep 2011 03:15:27 +0000 Subject: font_load(): Reduce font memory allocation to the font's file size if less than MAX_FONT_SIZE git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30618 a1c6a512-1295-4272-9138-f99709370657 --- firmware/font.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/font.c b/firmware/font.c index e6f90e4ca5..a8d8786259 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -550,7 +550,14 @@ int font_load_ex(const char *path, size_t buffer_size) } int font_load(const char *path) { - return font_load_ex(path, MAX_FONT_SIZE); + int size; + int fd = open( path, O_RDONLY ); + if ( fd < 0 ) + return -1; + size = filesize(fd); + if (size > MAX_FONT_SIZE) + size = MAX_FONT_SIZE; + return font_load_ex(path, size); } void font_unload(int font_id) -- cgit v1.2.3