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
This commit is contained in:
Cedric BAIL 2012-07-04 10:21:06 +00:00
parent 1d415b796b
commit 2e0fd1d375
2 changed files with 24 additions and 28 deletions

View File

@ -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;
}

View File

@ -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);
}