Index: trunk/i386/boot2/gui.c =================================================================== --- trunk/i386/boot2/gui.c (revision 1948) +++ trunk/i386/boot2/gui.c (revision 1949) @@ -202,6 +202,7 @@ }; int initFont(font_t *font, image_t *image); +int destroyFont(font_t *font); void colorFont(font_t *font, uint32_t color); void makeRoundedCorners(pixmap_t *p); @@ -432,6 +433,25 @@ return 0; } +static int unloadGraphics(void) +{ + int i; + + destroyFont(&font_console); + destroyFont(&font_small); + + for (i = 0; i < sizeof(images) / sizeof(images[0]); i++) + { + if (images[i].image) + { + if (images[i].image->pixels) free(images[i].image->pixels); + free (images[i].image); + images[i].image = 0; + } + } + return 0; +} + pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height ) { @@ -478,6 +498,19 @@ return 0; } +int freeBackBuffer( window_t *window ) +{ + if (gui.backbuffer && gui.backbuffer->pixels) + { + free(gui.backbuffer->pixels); + free(gui.backbuffer); + gui.backbuffer = 0; + return 0; + } + + return 1; +} + int createWindowBuffer( window_t *window ) { window->pixmap = malloc(sizeof(pixmap_t)); @@ -826,6 +859,14 @@ } } } + // not available memory, freeing resources + freeWindowBuffer(&gui.menu); + freeWindowBuffer(&gui.infobox); + freeWindowBuffer(&gui.bootprompt); + freeWindowBuffer(&gui.devicelist); + freeWindowBuffer(&gui.screen); + freeBackBuffer(&gui.screen); + unloadGraphics(); return 1; } @@ -1566,6 +1607,21 @@ return 0; } +int destroyFont(font_t *font) +{ + int i; + for (i = 0; i < CHARACTERS_COUNT; i++) + { + if (font->chars[i]) + { + if (font->chars[i]->pixels) free (font->chars[i]->pixels); + free (font->chars[i]); + font->chars[i] = 0; + } + } + return 0; +} + void colorFont(font_t *font, uint32_t color) { if( !color )