Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: plugin API - font_unload

plugin API - font_unload

From: Karl Koehler <koehlerkarl_at_comcast.net>
Date: Sat, 11 Dec 2010 12:14:16 -0800

Hi,

I'm just getting started with plugin development; and I already seem
to have some questions regarding the font API.
Namely, if I load a non-system font with

   struct font* font = (struct font*)malloc(sizeof(struct font));
   int fontId = rb->font_load(font, name);

    ...

then at the end, I feel I should be able to do
   rb->font_unload(fontId)

Now font_load doesn't know if the font was malloc'd or just a stack
variable in plugin_start, thus the system can not free the memory.
But if I just free the memory, then the slot will remain taken,
leading to a resource leak.
And possible crashes if another plugin want to use the same slot when
it's font-loading fails.

I see that rockpaint does only one font at a time, loading each to the
default slot, which seems wasteful in terms of CPU resources - it
doesn't seem right to load/unload all the time.
Do we have a way to unload fonts in the plugin-API ? ( I see there is
an API in firmware/export/font.h , but surely I should not be mucking
with this directly ?

Thanks,

  - Karl
Received on 2010-12-11


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa