ref: 3a664fca14a5bea8fadfffedc00e4e66109cf085
parent: 79ea4cd40c88579369fea37751618e32e2ee5ab4
author: David Turner <[email protected]>
date: Fri Dec 21 10:26:19 EST 2001
* src/cid/cidobjs.c (CID_Face_Done): fixed a memory leak, the subrs routines were never released when CID faces were destroyed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2001-12-21 David Turner <[email protected]>
+ * include/freetype/cache/ftcmanag.h, include/freetype/cache/ftcimage.h,
+ include/freetype/cache/ftcsbits.h: updating documentation to better
+ explain the use of the "anode" output parameter in lookup functions
+
* src/pshinter/pshglob.c (psh_globals_new): Replaced a floating
point constant with a fixed-float equivalent. For some reasons not
all compilers are capable of directly computing a floating pointer
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -170,6 +170,7 @@
/* */
/* anode :: used to return the address of of the corresponding */
/* cache node after incrementing its reference count */
+ /* (see note below) */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
--- a/include/freetype/cache/ftcmanag.h
+++ b/include/freetype/cache/ftcmanag.h
@@ -152,7 +152,7 @@
/* between abstract @FTC_FaceID values and real */
/* @FT_Face objects. */
/* */
- /* families :: XXX */
+ /* families :: global table of families. */
/* */
typedef struct FTC_ManagerRec_
{
--- a/include/freetype/cache/ftcsbits.h
+++ b/include/freetype/cache/ftcsbits.h
@@ -164,10 +164,9 @@
/* <Output> */
/* sbit :: A handle to a small bitmap descriptor. */
/* */
- /* anode :: An opaque cache node pointer that will be used */
- /* to release the sbit once it becomes unuseful. */
- /* Can be NULL, in which case this function will */
- /* have the same effect as @FTC_SBitCache_Lookup. XXX */
+ /* anode :: used to return the address of of the corresponding */
+ /* cache node after incrementing its reference count */
+ /* (see note below) */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -180,6 +179,17 @@
/* */
/* The descriptor's `buffer' field is set to 0 to indicate a missing */
/* glyph bitmap. */
+ /* */
+ /* If "anode" is _not_ NULL, it receives the address of the cache */
+ /* node containing the bitmap, after increasing its reference */
+ /* count. This ensures that the node (as well as the image) will */
+ /* always be kept in the cache until you call @FTC_Node_Unref to */
+ /* "release" it. */
+ /* */
+ /* If "anode" is NULL, the cache node is left unchanged, which means */
+ /* that the bitmap could be flushed out of the cache on the next */
+ /* call to one of the caching sub-system APIs. Just don't assume */
+ /* that it's persistent.. */
/* */
FT_EXPORT( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache,
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -446,7 +446,7 @@
if ( FILE_Seek( cid->data_offset + offsets[0] ) ||
FILE_Read( subr->code[0], data_len ) )
- goto Exit;
+ goto Fail;
/* set up pointers */
for ( count = 1; count <= num_subrs; count++ )
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -196,6 +196,25 @@
memory = face->root.memory;
+ /* release subrs */
+ if ( face->subrs )
+ {
+ FT_Int n;
+
+ for ( n = 0; n < cid->num_dicts; n++ )
+ {
+ CID_Subrs* subr = face->subrs + n;
+
+ if ( subr->code )
+ {
+ FREE( subr->code[0] );
+ FREE( subr->code );
+ }
+ }
+
+ FREE( face->subrs );
+ }
+
/* release FontInfo strings */
FREE( info->version );
FREE( info->notice );
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -123,7 +123,7 @@
size->root.metrics.x_scale,
size->root.metrics.y_scale,
0, 0 );
- return error;
+ return error;
}