From 637dd1764723d1ae8a948935e8505c40a8799472 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 21 Dec 2001 15:26:19 +0000 Subject: [PATCH] * src/cid/cidobjs.c (CID_Face_Done): fixed a memory leak, the subrs routines were never released when CID faces were destroyed --- ChangeLog | 4 ++++ include/freetype/cache/ftcimage.h | 1 + include/freetype/cache/ftcmanag.h | 2 +- include/freetype/cache/ftcsbits.h | 18 ++++++++++++++---- src/cid/cidload.c | 2 +- src/cid/cidobjs.c | 19 +++++++++++++++++++ src/type1/t1objs.c | 2 +- 7 files changed, 41 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 191ab7b28..699a5538f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2001-12-21 David Turner + * 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 diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h index bc75466c6..f12ee2971 100644 --- a/include/freetype/cache/ftcimage.h +++ b/include/freetype/cache/ftcimage.h @@ -170,6 +170,7 @@ FT_BEGIN_HEADER /* */ /* anode :: used to return the address of of the corresponding */ /* cache node after incrementing its reference count */ + /* (see note below) */ /* */ /* */ /* FreeType error code. 0 means success. */ diff --git a/include/freetype/cache/ftcmanag.h b/include/freetype/cache/ftcmanag.h index 44e2dab85..7db644cb5 100644 --- a/include/freetype/cache/ftcmanag.h +++ b/include/freetype/cache/ftcmanag.h @@ -152,7 +152,7 @@ FT_BEGIN_HEADER /* between abstract @FTC_FaceID values and real */ /* @FT_Face objects. */ /* */ - /* families :: XXX */ + /* families :: global table of families. */ /* */ typedef struct FTC_ManagerRec_ { diff --git a/include/freetype/cache/ftcsbits.h b/include/freetype/cache/ftcsbits.h index 8e04c8946..181cfd242 100644 --- a/include/freetype/cache/ftcsbits.h +++ b/include/freetype/cache/ftcsbits.h @@ -164,10 +164,9 @@ FT_BEGIN_HEADER /* */ /* 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) */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -181,6 +180,17 @@ FT_BEGIN_HEADER /* 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, FTC_ImageDesc* desc, diff --git a/src/cid/cidload.c b/src/cid/cidload.c index ad3901391..561129198 100644 --- 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++ ) diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index e2eb67954..2d1e6b302 100644 --- 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 ); diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 34f29fe58..4d4faf004 100644 --- 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; }