evas: make the code do what we expect by destroying Glyph at the right time.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jul 2012 10:21:06 +0000 (10:21 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jul 2012 10:21:06 +0000 (10:21 +0000)
This fix the leak issue that was added lately and make the code
more easy to follow.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@73265 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_font_load.c
src/lib/engines/common/evas_font_main.c

index 4024565..42628be 100644 (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;
           }
index 100f3b7..e51a935 100644 (file)
@@ -296,11 +296,33 @@ _fash_int_add(Fash_Int *fash, int item, RGBA_Font_Int *fint, int 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);
 }