From 2e0fd1d375ee62ca0dead9b15462c570473c5857 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 4 Jul 2012 10:21:06 +0000 Subject: [PATCH] evas: make the code do what we expect by destroying Glyph at the right time. This fix the leak issue that was added lately and make the code more easy to follow. SVN revision: 73265 --- .../src/lib/engines/common/evas_font_load.c | 27 ------------------- .../src/lib/engines/common/evas_font_main.c | 25 ++++++++++++++++- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c index 4024565760..42628be7ed 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_load.c +++ b/legacy/evas/src/lib/engines/common/evas_font_load.c @@ -749,33 +749,6 @@ _evas_common_font_int_clear(RGBA_Font_Int *fi) { if (fi->fash) { - for (k = 0; k <= 0xff; k++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) - { - Fash_Glyph_Map2 *fmap2 = fi->fash->bucket[k]; - if (fmap2) - { - for (j = 0; j <= 0xff; j++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) - { - Fash_Glyph_Map *fmap = fmap2->bucket[j]; - if (fmap) - { - for (i = 0; i <= 0xff; i++) - { - RGBA_Font_Glyph *fg = fmap->item[i]; - if ((fg) && (fg != (void *)(-1))) - { - FT_Done_Glyph(fg->glyph); - /* extension calls */ - if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat); - if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out); - free(fg); - fmap->item[i] = NULL; - } - } - } - } - } - } fi->fash->freeme(fi->fash); fi->fash = NULL; } diff --git a/legacy/evas/src/lib/engines/common/evas_font_main.c b/legacy/evas/src/lib/engines/common/evas_font_main.c index 100f3b7523..e51a935bff 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_main.c +++ b/legacy/evas/src/lib/engines/common/evas_font_main.c @@ -295,12 +295,34 @@ _fash_int_add(Fash_Int *fash, int item, RGBA_Font_Int *fint, int idx) fash->bucket[grp]->bucket[maj]->item[min].index = idx; } +static void +_fash_glyph_free(Fash_Glyph_Map *fmap) +{ + int i; + + for (i = 0; i <= 0xff; i++) + { + RGBA_Font_Glyph *fg = fmap->item[i]; + if ((fg) && (fg != (void *)(-1))) + { + FT_Done_Glyph(fg->glyph); + /* extension calls */ + if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat); + if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out); + free(fg); + fmap->item[i] = NULL; + } + } + free(fmap); +} + static void _fash_gl2_free(Fash_Glyph_Map2 *fash) { int i; - for (i = 0; i < 256; i++) if (fash->bucket[i]) free(fash->bucket[i]); + // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) + for (i = 0; i < 256; i++) if (fash->bucket[i]) _fash_glyph_free(fash->bucket[i]); free(fash); } @@ -309,6 +331,7 @@ _fash_gl_free(Fash_Glyph *fash) { int i; + // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) for (i = 0; i < 256; i++) if (fash->bucket[i]) _fash_gl2_free(fash->bucket[i]); free(fash); }