[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] charmaps memory management
From: |
Masatake YAMATO |
Subject: |
[Devel] charmaps memory management |
Date: |
Sat, 03 Jan 2004 01:24:56 +0900 (JST) |
It seems that charmaps array and its elements in FT_Face are not freed
if clazz->init_face() invocation returns an error.
The attached patch fix this issue.
Masatake YAMATO
2004-01-03 Masatake YAMATO <address@hidden>
* src/base/ftobjs.c (discard_charmaps): New function.
(destroy_face): Use `discard_charmaps'.
(open_face): Ditto.
Index: src/base/ftobjs.c
===================================================================
RCS file: /cvsroot/freetype2/src/base/ftobjs.c,v
retrieving revision 1.194
diff -u -r1.194 ftobjs.c
--- ftobjs.c 2003/12/27 21:44:18 1.194
+++ ftobjs.c 2004/01/02 16:21:19
@@ -668,7 +668,25 @@
FT_FREE( size );
}
+ static void
+ discard_charmaps( FT_Face face, FT_Memory memory )
+ {
+ FT_Int n;
+
+ for ( n = 0; n < face->num_charmaps; n++ )
+ {
+ FT_CMap cmap = FT_CMAP( face->charmaps[n] );
+
+
+ FT_CMap_Done( cmap );
+ face->charmaps[n] = NULL;
+ }
+
+ FT_FREE( face->charmaps );
+ face->num_charmaps = 0;
+ }
+
/* destructor for faces list */
static void
destroy_face( FT_Memory memory,
@@ -699,25 +717,8 @@
face->generic.finalizer( face );
/* discard charmaps */
- {
- FT_Int n;
-
-
- for ( n = 0; n < face->num_charmaps; n++ )
- {
- FT_CMap cmap = FT_CMAP( face->charmaps[n] );
-
-
- FT_CMap_Done( cmap );
-
- face->charmaps[n] = NULL;
- }
-
- FT_FREE( face->charmaps );
- face->num_charmaps = 0;
- }
-
-
+ discard_charmaps ( face, memory );
+
/* finalize format-specific stuff */
if ( clazz->done_face )
clazz->done_face( face );
@@ -924,6 +925,7 @@
Fail:
if ( error )
{
+ discard_charmaps ( face, memory );
clazz->done_face( face );
FT_FREE( internal );
FT_FREE( face );
- [Devel] charmaps memory management,
Masatake YAMATO <=