diff --git a/src/ftglue.c b/src/ftglue.c index 752c976fb..9fd0f41f3 100644 --- a/src/ftglue.c +++ b/src/ftglue.c @@ -30,16 +30,15 @@ _hb_ftglue_log( const char* format, ... ) /* only used internally */ static FT_Pointer -_hb_ftglue_qalloc( FT_Memory memory, - FT_ULong size, - HB_Error *perror ) +_hb_ftglue_qalloc( FT_ULong size, + HB_Error *perror ) { HB_Error error = 0; FT_Pointer block = NULL; if ( size > 0 ) { - block = memory->alloc( memory, size ); + block = malloc( size ); if ( !block ) error = HB_Err_Out_Of_Memory; } @@ -49,20 +48,19 @@ _hb_ftglue_qalloc( FT_Memory memory, } #undef QALLOC /* just in case */ -#define QALLOC(ptr,size) ( (ptr) = _hb_ftglue_qalloc( memory, (size), &error ), error != 0 ) +#define QALLOC(ptr,size) ( (ptr) = _hb_ftglue_qalloc( (size), &error ), error != 0 ) FTGLUE_APIDEF( FT_Pointer ) -_hb_ftglue_alloc( FT_Memory memory, - FT_ULong size, - HB_Error *perror ) +_hb_ftglue_alloc( FT_ULong size, + HB_Error *perror ) { HB_Error error = 0; FT_Pointer block = NULL; if ( size > 0 ) { - block = memory->alloc( memory, size ); + block = malloc( size ); if ( !block ) error = HB_Err_Out_Of_Memory; else @@ -75,31 +73,16 @@ _hb_ftglue_alloc( FT_Memory memory, FTGLUE_APIDEF( FT_Pointer ) -_hb_ftglue_realloc( FT_Memory memory, - FT_Pointer block, - FT_ULong old_size, - FT_ULong new_size, - HB_Error *perror ) +_hb_ftglue_realloc( FT_Pointer block, + FT_ULong new_size, + HB_Error *perror ) { FT_Pointer block2 = NULL; HB_Error error = 0; - if ( old_size == 0 || block == NULL ) - { - block2 = _hb_ftglue_alloc( memory, new_size, &error ); - } - else if ( new_size == 0 ) - { - _hb_ftglue_free( memory, block ); - } - else - { - block2 = memory->realloc( memory, old_size, new_size, block ); - if ( block2 == NULL ) - error = HB_Err_Out_Of_Memory; - else if ( new_size > old_size ) - memset( (char*)block2 + old_size, 0, (size_t)(new_size - old_size) ); - } + block2 = realloc( block, new_size ); + if ( block2 == NULL && new_size != 0 ) + error = HB_Err_Out_Of_Memory; if ( !error ) block = block2; @@ -110,11 +93,10 @@ _hb_ftglue_realloc( FT_Memory memory, FTGLUE_APIDEF( void ) -_hb_ftglue_free( FT_Memory memory, - FT_Pointer block ) +_hb_ftglue_free( FT_Pointer block ) { if ( block ) - memory->free( memory, block ); + free( block ); } @@ -156,8 +138,6 @@ _hb_ftglue_stream_frame_enter( FT_Stream stream, if ( stream->read ) { /* allocate the frame in memory */ - FT_Memory memory = stream->memory; - if ( QALLOC( stream->base, count ) ) goto Exit; @@ -201,8 +181,6 @@ _hb_ftglue_stream_frame_exit( FT_Stream stream ) { if ( stream->read ) { - FT_Memory memory = stream->memory; - FREE( stream->base ); } stream->cursor = NULL; diff --git a/src/ftglue.h b/src/ftglue.h index 9b237dda0..1e13a2c4a 100644 --- a/src/ftglue.h +++ b/src/ftglue.h @@ -112,16 +112,16 @@ _hb_ftglue_face_goto_table( FT_Face face, /* memory macros used by the OpenType parser */ #define ALLOC(_ptr,_size) \ - ( (_ptr) = _hb_ftglue_alloc( memory, _size, &error ), error != 0 ) + ( (_ptr) = _hb_ftglue_alloc( _size, &error ), error != 0 ) -#define REALLOC(_ptr,_oldsz,_newsz) \ - ( (_ptr) = _hb_ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 ) +#define REALLOC(_ptr,_newsz) \ + ( (_ptr) = _hb_ftglue_realloc( (_ptr), (_newsz), &error ), error != 0 ) #define FREE(_ptr) \ do { \ if ( (_ptr) ) \ { \ - _hb_ftglue_free( memory, _ptr ); \ + _hb_ftglue_free( _ptr ); \ _ptr = NULL; \ } \ } while (0) @@ -129,27 +129,23 @@ _hb_ftglue_face_goto_table( FT_Face face, #define ALLOC_ARRAY(_ptr,_count,_type) \ ALLOC(_ptr,(_count)*sizeof(_type)) -#define REALLOC_ARRAY(_ptr,_oldcnt,_newcnt,_type) \ - REALLOC(_ptr,(_oldcnt)*sizeof(_type),(_newcnt)*sizeof(_type)) +#define REALLOC_ARRAY(_ptr,_newcnt,_type) \ + REALLOC(_ptr,(_newcnt)*sizeof(_type)) #define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) ) FTGLUE_API( FT_Pointer ) -_hb_ftglue_alloc( FT_Memory memory, - FT_ULong size, - HB_Error *perror_ ); +_hb_ftglue_alloc( FT_ULong size, + HB_Error *perror_ ); FTGLUE_API( FT_Pointer ) -_hb_ftglue_realloc( FT_Memory memory, - FT_Pointer block, - FT_ULong old_size, - FT_ULong new_size, - HB_Error *perror_ ); +_hb_ftglue_realloc( FT_Pointer block, + FT_ULong new_size, + HB_Error *perror_ ); FTGLUE_API( void ) -_hb_ftglue_free( FT_Memory memory, - FT_Pointer block ); +_hb_ftglue_free( FT_Pointer block ); /* abuse these private header/source files */ diff --git a/src/harfbuzz-buffer.c b/src/harfbuzz-buffer.c index 148d98d92..f597ac9af 100644 --- a/src/harfbuzz-buffer.c +++ b/src/harfbuzz-buffer.c @@ -42,7 +42,6 @@ static HB_Error hb_buffer_ensure( HB_Buffer buffer, FT_ULong size ) { - FT_Memory memory = buffer->memory; FT_ULong new_allocated = buffer->allocated; if (size > new_allocated) @@ -52,9 +51,9 @@ hb_buffer_ensure( HB_Buffer buffer, while (size > new_allocated) new_allocated += (new_allocated >> 1) + 8; - if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, HB_PositionRec ) ) + if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) ) return error; - if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) ) + if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) ) return error; if ( buffer->inplace ) { @@ -62,13 +61,13 @@ hb_buffer_ensure( HB_Buffer buffer, if ( buffer->alt_string ) { - if ( REALLOC_ARRAY( buffer->alt_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) ) + if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) ) return error; } } else { - if ( REALLOC_ARRAY( buffer->alt_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) ) + if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) ) return error; buffer->out_string = buffer->alt_string; @@ -85,7 +84,6 @@ hb_buffer_duplicate_out_buffer( HB_Buffer buffer ) { if ( !buffer->alt_string ) { - FT_Memory memory = buffer->memory; HB_Error error; if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) ) @@ -100,15 +98,13 @@ hb_buffer_duplicate_out_buffer( HB_Buffer buffer ) } HB_Error -hb_buffer_new( FT_Memory memory, - HB_Buffer *buffer ) +hb_buffer_new( HB_Buffer *buffer ) { HB_Error error; if ( ALLOC( *buffer, sizeof( HB_BufferRec ) ) ) return error; - (*buffer)->memory = memory; (*buffer)->in_length = 0; (*buffer)->out_length = 0; (*buffer)->allocated = 0; @@ -161,8 +157,6 @@ hb_buffer_swap( HB_Buffer buffer ) void hb_buffer_free( HB_Buffer buffer ) { - FT_Memory memory = buffer->memory; - FREE( buffer->in_string ); FREE( buffer->alt_string ); buffer->out_string = NULL; diff --git a/src/harfbuzz-buffer.h b/src/harfbuzz-buffer.h index 8b6b659f6..9adfc5736 100644 --- a/src/harfbuzz-buffer.h +++ b/src/harfbuzz-buffer.h @@ -48,7 +48,6 @@ typedef struct HB_PositionRec_ { typedef struct HB_BufferRec_{ - FT_Memory memory; FT_ULong allocated; FT_ULong in_length; @@ -65,8 +64,7 @@ typedef struct HB_BufferRec_{ } HB_BufferRec, *HB_Buffer; HB_Error -hb_buffer_new( FT_Memory memory, - HB_Buffer *buffer ); +hb_buffer_new( HB_Buffer *buffer ); void hb_buffer_swap( HB_Buffer buffer ); diff --git a/src/harfbuzz-gdef.c b/src/harfbuzz-gdef.c index 859c81bb5..2ba6b1ab0 100644 --- a/src/harfbuzz-gdef.c +++ b/src/harfbuzz-gdef.c @@ -19,13 +19,9 @@ static HB_Error Load_AttachList( HB_AttachList* al, static HB_Error Load_LigCaretList( HB_LigCaretList* lcl, FT_Stream stream ); -static void Free_AttachList( HB_AttachList* al, - FT_Memory memory ); -static void Free_LigCaretList( HB_LigCaretList* lcl, - FT_Memory memory ); - -static void Free_NewGlyphClasses( HB_GDEFHeader* gdef, - FT_Memory memory ); +static void Free_AttachList( HB_AttachList* al ); +static void Free_LigCaretList( HB_LigCaretList* lcl ); +static void Free_NewGlyphClasses( HB_GDEFHeader* gdef ); @@ -89,12 +85,12 @@ static HB_Error GDEF_Destroy( void* ext, if ( gdef->loaded ) { - Free_LigCaretList( &gdef->LigCaretList, memory ); - Free_AttachList( &gdef->AttachList, memory ); - _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef, memory ); + Free_LigCaretList( &gdef->LigCaretList ); + Free_AttachList( &gdef->AttachList ); + _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef ); + _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef ); - Free_NewGlyphClasses( gdef, memory ); + Free_NewGlyphClasses( gdef ); } return HB_Err_Ok; @@ -130,11 +126,9 @@ HB_Error HB_Init_GDEF_Extension( HB_Engine engine ) -HB_Error HB_New_GDEF_Table( FT_Face face, - HB_GDEFHeader** retptr ) +HB_Error HB_New_GDEF_Table( HB_GDEFHeader** retptr ) { HB_Error error; - FT_Memory memory = face->memory; HB_GDEFHeader* gdef; @@ -144,8 +138,6 @@ HB_Error HB_New_GDEF_Table( FT_Face face, if ( ALLOC( gdef, sizeof( *gdef ) ) ) return error; - gdef->memory = face->memory; - gdef->GlyphClassDef.loaded = FALSE; gdef->AttachList.loaded = FALSE; gdef->LigCaretList.loaded = FALSE; @@ -165,7 +157,6 @@ HB_Error HB_Load_GDEF_Table( FT_Face face, HB_GDEFHeader** retptr ) { HB_Error error; - FT_Memory memory = face->memory; FT_Stream stream = face->stream; FT_ULong cur_offset, new_offset, base_offset; @@ -178,7 +169,7 @@ HB_Error HB_Load_GDEF_Table( FT_Face face, if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) )) return error; - if (( error = HB_New_GDEF_Table ( face, &gdef ) )) + if (( error = HB_New_GDEF_Table ( &gdef ) )) return error; base_offset = FILE_Pos(); @@ -268,13 +259,13 @@ HB_Error HB_Load_GDEF_Table( FT_Face face, return HB_Err_Ok; Fail3: - Free_LigCaretList( &gdef->LigCaretList, memory ); + Free_LigCaretList( &gdef->LigCaretList ); Fail2: - Free_AttachList( &gdef->AttachList, memory ); + Free_AttachList( &gdef->AttachList ); Fail1: - _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef ); Fail0: FREE( gdef ); @@ -285,14 +276,12 @@ Fail0: HB_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef ) { - FT_Memory memory = gdef->memory; + Free_LigCaretList( &gdef->LigCaretList ); + Free_AttachList( &gdef->AttachList ); + _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef ); + _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef ); - Free_LigCaretList( &gdef->LigCaretList, memory ); - Free_AttachList( &gdef->AttachList, memory ); - _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef, memory ); - - Free_NewGlyphClasses( gdef, memory ); + Free_NewGlyphClasses( gdef ); FREE( gdef ); @@ -312,7 +301,6 @@ HB_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef ) static HB_Error Load_AttachPoint( HB_AttachPoint* ap, FT_Stream stream ) { - FT_Memory memory = stream->memory; HB_Error error; FT_UShort n, count; @@ -351,8 +339,7 @@ static HB_Error Load_AttachPoint( HB_AttachPoint* ap, } -static void Free_AttachPoint( HB_AttachPoint* ap, - FT_Memory memory ) +static void Free_AttachPoint( HB_AttachPoint* ap ) { FREE( ap->PointIndex ); } @@ -363,7 +350,6 @@ static void Free_AttachPoint( HB_AttachPoint* ap, static HB_Error Load_AttachList( HB_AttachList* al, FT_Stream stream ) { - FT_Memory memory = stream->memory; HB_Error error; FT_UShort n, m, count; @@ -423,18 +409,17 @@ static HB_Error Load_AttachList( HB_AttachList* al, Fail1: for ( m = 0; m < n; m++ ) - Free_AttachPoint( &ap[m], memory ); + Free_AttachPoint( &ap[m] ); FREE( ap ); Fail2: - _HB_OPEN_Free_Coverage( &al->Coverage, memory ); + _HB_OPEN_Free_Coverage( &al->Coverage ); return error; } -static void Free_AttachList( HB_AttachList* al, - FT_Memory memory ) +static void Free_AttachList( HB_AttachList* al ) { FT_UShort n, count; @@ -450,12 +435,12 @@ static void Free_AttachList( HB_AttachList* al, ap = al->AttachPoint; for ( n = 0; n < count; n++ ) - Free_AttachPoint( &ap[n], memory ); + Free_AttachPoint( &ap[n] ); FREE( ap ); } - _HB_OPEN_Free_Coverage( &al->Coverage, memory ); + _HB_OPEN_Free_Coverage( &al->Coverage ); } @@ -545,11 +530,10 @@ static HB_Error Load_CaretValue( HB_CaretValue* cv, } -static void Free_CaretValue( HB_CaretValue* cv, - FT_Memory memory ) +static void Free_CaretValue( HB_CaretValue* cv ) { if ( cv->CaretValueFormat == 3 ) - _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device, memory ); + _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device ); } @@ -558,7 +542,6 @@ static void Free_CaretValue( HB_CaretValue* cv, static HB_Error Load_LigGlyph( HB_LigGlyph* lg, FT_Stream stream ) { - FT_Memory memory = stream->memory; HB_Error error; FT_UShort n, m, count; @@ -603,15 +586,14 @@ static HB_Error Load_LigGlyph( HB_LigGlyph* lg, Fail: for ( m = 0; m < n; m++ ) - Free_CaretValue( &cv[m], memory ); + Free_CaretValue( &cv[m] ); FREE( cv ); return error; } -static void Free_LigGlyph( HB_LigGlyph* lg, - FT_Memory memory ) +static void Free_LigGlyph( HB_LigGlyph* lg ) { FT_UShort n, count; @@ -624,7 +606,7 @@ static void Free_LigGlyph( HB_LigGlyph* lg, cv = lg->CaretValue; for ( n = 0; n < count; n++ ) - Free_CaretValue( &cv[n], memory ); + Free_CaretValue( &cv[n] ); FREE( cv ); } @@ -636,7 +618,6 @@ static void Free_LigGlyph( HB_LigGlyph* lg, static HB_Error Load_LigCaretList( HB_LigCaretList* lcl, FT_Stream stream ) { - FT_Memory memory = stream->memory; HB_Error error; FT_UShort m, n, count; @@ -696,18 +677,17 @@ static HB_Error Load_LigCaretList( HB_LigCaretList* lcl, Fail1: for ( m = 0; m < n; m++ ) - Free_LigGlyph( &lg[m], memory ); + Free_LigGlyph( &lg[m] ); FREE( lg ); Fail2: - _HB_OPEN_Free_Coverage( &lcl->Coverage, memory ); + _HB_OPEN_Free_Coverage( &lcl->Coverage ); return error; } -static void Free_LigCaretList( HB_LigCaretList* lcl, - FT_Memory memory ) +static void Free_LigCaretList( HB_LigCaretList* lcl ) { FT_UShort n, count; @@ -723,12 +703,12 @@ static void Free_LigCaretList( HB_LigCaretList* lcl, lg = lcl->LigGlyph; for ( n = 0; n < count; n++ ) - Free_LigGlyph( &lg[n], memory ); + Free_LigGlyph( &lg[n] ); FREE( lg ); } - _HB_OPEN_Free_Coverage( &lcl->Coverage, memory ); + _HB_OPEN_Free_Coverage( &lcl->Coverage ); } @@ -845,8 +825,7 @@ HB_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef, static HB_Error Make_ClassRange( HB_ClassDefinition* cd, FT_UShort start, FT_UShort end, - FT_UShort class, - FT_Memory memory ) + FT_UShort class ) { HB_Error error; FT_UShort index; @@ -858,7 +837,6 @@ static HB_Error Make_ClassRange( HB_ClassDefinition* cd, cdf2 = &cd->cd.cd2; if ( REALLOC_ARRAY( cdf2->ClassRangeRecord, - cdf2->ClassRangeCount, cdf2->ClassRangeCount + 1 , HB_ClassRangeRecord ) ) return error; @@ -888,7 +866,6 @@ HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef, FT_UShort start, curr_glyph, curr_class; FT_UShort n, m, count; HB_Error error; - FT_Memory memory; HB_ClassDefinition* gcd; HB_ClassRangeRecord* gcrr; @@ -898,7 +875,6 @@ HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef, if ( !gdef || !glyph_array || !class_array ) return HB_Err_Invalid_Argument; - memory = gdef->memory; gcd = &gdef->GlyphClassDef; /* We build a format 2 table */ @@ -933,8 +909,7 @@ HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef, { if ( ( error = Make_ClassRange( gcd, start, curr_glyph, - curr_class, - memory ) ) != HB_Err_Ok ) + curr_class ) ) != HB_Err_Ok ) goto Fail3; } else @@ -952,8 +927,7 @@ HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef, { if ( ( error = Make_ClassRange( gcd, start, curr_glyph - 1, - curr_class, - memory ) ) != HB_Err_Ok ) + curr_class ) ) != HB_Err_Ok ) goto Fail3; if ( curr_glyph > glyph_array[n] ) @@ -976,8 +950,7 @@ HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef, { if ( ( error = Make_ClassRange( gcd, start, curr_glyph, - curr_class, - memory ) ) != HB_Err_Ok ) + curr_class ) ) != HB_Err_Ok ) goto Fail3; } else @@ -1065,8 +1038,7 @@ Fail4: } -static void Free_NewGlyphClasses( HB_GDEFHeader* gdef, - FT_Memory memory ) +static void Free_NewGlyphClasses( HB_GDEFHeader* gdef ) { FT_UShort** ngc; FT_UShort n, count; diff --git a/src/harfbuzz-gdef.h b/src/harfbuzz-gdef.h index 59e14b976..b752af6fe 100644 --- a/src/harfbuzz-gdef.h +++ b/src/harfbuzz-gdef.h @@ -81,7 +81,6 @@ typedef struct HB_LigCaretList_ HB_LigCaretList; struct HB_GDEFHeader_ { - FT_Memory memory; FT_ULong offset; FT_Fixed Version; @@ -100,11 +99,10 @@ typedef struct HB_GDEFHeader_ HB_GDEFHeader; typedef struct HB_GDEFHeader_* HB_GDEF; -HB_Error HB_New_GDEF_Table( FT_Face face, - HB_GDEFHeader** retptr ); +HB_Error HB_New_GDEF_Table( HB_GDEFHeader** retptr ); -HB_Error HB_Load_GDEF_Table( FT_Face face, +HB_Error HB_Load_GDEF_Table( FT_Face face, HB_GDEFHeader** gdef ); diff --git a/src/harfbuzz-gpos-private.h b/src/harfbuzz-gpos-private.h index a36f3a48c..ef3c750f1 100644 --- a/src/harfbuzz-gpos-private.h +++ b/src/harfbuzz-gpos-private.h @@ -675,7 +675,6 @@ HB_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st, FT_UShort lookup_type ); void _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st, - FT_Memory memory, FT_UShort lookup_type ); FT_END_HEADER diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c index e3486f0de..5c91f6eaf 100644 --- a/src/harfbuzz-gpos.c +++ b/src/harfbuzz-gpos.c @@ -70,7 +70,6 @@ HB_Error HB_Load_GPOS_Table( FT_Face face, FT_Stream stream = face->stream; HB_Error error; - FT_Memory memory = face->memory; if ( !retptr ) @@ -84,7 +83,6 @@ HB_Error HB_Load_GPOS_Table( FT_Face face, if ( ALLOC ( gpos, sizeof( *gpos ) ) ) return error; - gpos->memory = memory; gpos->gfunc = FT_Load_Glyph; gpos->mmfunc = default_mmfunc; @@ -168,13 +166,13 @@ HB_Error HB_Load_GPOS_Table( FT_Face face, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS, memory ); + _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS ); Fail2: - _HB_OPEN_Free_FeatureList( &gpos->FeatureList, memory ); + _HB_OPEN_Free_FeatureList( &gpos->FeatureList ); Fail3: - _HB_OPEN_Free_ScriptList( &gpos->ScriptList, memory ); + _HB_OPEN_Free_ScriptList( &gpos->ScriptList ); Fail4: FREE( gpos ); @@ -185,11 +183,9 @@ Fail4: HB_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos ) { - FT_Memory memory = gpos->memory; - - _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS, memory ); - _HB_OPEN_Free_FeatureList( &gpos->FeatureList, memory ); - _HB_OPEN_Free_ScriptList( &gpos->ScriptList, memory ); + _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS ); + _HB_OPEN_Free_FeatureList( &gpos->FeatureList ); + _HB_OPEN_Free_ScriptList( &gpos->ScriptList ); FREE( gpos ); @@ -215,7 +211,6 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_ULong cur_offset, new_offset; @@ -443,29 +438,28 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_Device( &vr->YAdvanceDevice, memory ); + _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); Fail2: - _HB_OPEN_Free_Device( &vr->XAdvanceDevice, memory ); + _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); Fail3: - _HB_OPEN_Free_Device( &vr->YPlacementDevice, memory ); + _HB_OPEN_Free_Device( &vr->YPlacementDevice ); return error; } static void Free_ValueRecord( HB_ValueRecord* vr, - FT_UShort format, - FT_Memory memory ) + FT_UShort format ) { if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->YAdvanceDevice, memory ); + _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->XAdvanceDevice, memory ); + _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->YPlacementDevice, memory ); + _HB_OPEN_Free_Device( &vr->YPlacementDevice ); if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->XPlacementDevice, memory ); + _HB_OPEN_Free_Device( &vr->XPlacementDevice ); } @@ -576,7 +570,6 @@ static HB_Error Load_Anchor( HB_Anchor* an, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_ULong cur_offset, new_offset, base_offset; @@ -685,18 +678,17 @@ static HB_Error Load_Anchor( HB_Anchor* an, return HB_Err_Ok; Fail: - _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable, memory ); + _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable ); return error; } -static void Free_Anchor( HB_Anchor* an, - FT_Memory memory) +static void Free_Anchor( HB_Anchor* an ) { if ( an->PosFormat == 3 ) { - _HB_OPEN_Free_Device( &an->af.af3.YDeviceTable, memory ); - _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable, memory ); + _HB_OPEN_Free_Device( &an->af.af3.YDeviceTable ); + _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable ); } } @@ -815,7 +807,6 @@ static HB_Error Load_MarkArray ( HB_MarkArray* ma, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -860,15 +851,14 @@ static HB_Error Load_MarkArray ( HB_MarkArray* ma, Fail: for ( m = 0; m < n; m++ ) - Free_Anchor( &mr[m].MarkAnchor, memory ); + Free_Anchor( &mr[m].MarkAnchor ); FREE( mr ); return error; } -static void Free_MarkArray( HB_MarkArray* ma, - FT_Memory memory ) +static void Free_MarkArray( HB_MarkArray* ma ) { FT_UShort n, count; @@ -881,7 +871,7 @@ static void Free_MarkArray( HB_MarkArray* ma, mr = ma->MarkRecord; for ( n = 0; n < count; n++ ) - Free_Anchor( &mr[n].MarkAnchor, memory ); + Free_Anchor( &mr[n].MarkAnchor ); FREE( mr ); } @@ -897,7 +887,6 @@ static HB_Error Load_SinglePos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_SinglePos* sp = &st->single; FT_UShort n, m, count, format; @@ -967,18 +956,17 @@ static HB_Error Load_SinglePos( HB_GPOS_SubTable* st, Fail1: for ( m = 0; m < n; m++ ) - Free_ValueRecord( &vr[m], format, memory ); + Free_ValueRecord( &vr[m], format ); FREE( vr ); Fail2: - _HB_OPEN_Free_Coverage( &sp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &sp->Coverage ); return error; } -static void Free_SinglePos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_SinglePos( HB_GPOS_SubTable* st ) { FT_UShort n, count, format; HB_SinglePos* sp = &st->single; @@ -991,7 +979,7 @@ static void Free_SinglePos( HB_GPOS_SubTable* st, switch ( sp->PosFormat ) { case 1: - Free_ValueRecord( &sp->spf.spf1.Value, format, memory ); + Free_ValueRecord( &sp->spf.spf1.Value, format ); break; case 2: @@ -1001,7 +989,7 @@ static void Free_SinglePos( HB_GPOS_SubTable* st, v = sp->spf.spf2.Value; for ( n = 0; n < count; n++ ) - Free_ValueRecord( &v[n], format, memory ); + Free_ValueRecord( &v[n], format ); FREE( v ); } @@ -1010,7 +998,7 @@ static void Free_SinglePos( HB_GPOS_SubTable* st, break; } - _HB_OPEN_Free_Coverage( &sp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &sp->Coverage ); } static HB_Error Lookup_SinglePos( GPOS_Instance* gpi, @@ -1075,7 +1063,6 @@ static HB_Error Load_PairSet ( HB_PairSet* ps, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong base_offset; @@ -1122,7 +1109,7 @@ static HB_Error Load_PairSet ( HB_PairSet* ps, if ( error ) { if ( format1 ) - Free_ValueRecord( &pvr[n].Value1, format1, memory ); + Free_ValueRecord( &pvr[n].Value1, format1 ); goto Fail; } } @@ -1134,9 +1121,9 @@ Fail: for ( m = 0; m < n; m++ ) { if ( format1 ) - Free_ValueRecord( &pvr[m].Value1, format1, memory ); + Free_ValueRecord( &pvr[m].Value1, format1 ); if ( format2 ) - Free_ValueRecord( &pvr[m].Value2, format2, memory ); + Free_ValueRecord( &pvr[m].Value2, format2 ); } FREE( pvr ); @@ -1146,8 +1133,7 @@ Fail: static void Free_PairSet( HB_PairSet* ps, FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) + FT_UShort format2 ) { FT_UShort n, count; @@ -1162,9 +1148,9 @@ static void Free_PairSet( HB_PairSet* ps, for ( n = 0; n < count; n++ ) { if ( format1 ) - Free_ValueRecord( &pvr[n].Value1, format1, memory ); + Free_ValueRecord( &pvr[n].Value1, format1 ); if ( format2 ) - Free_ValueRecord( &pvr[n].Value2, format2, memory ); + Free_ValueRecord( &pvr[n].Value2, format2 ); } FREE( pvr ); @@ -1180,7 +1166,6 @@ static HB_Error Load_PairPos1( HB_PairPosFormat1* ppf1, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1225,7 +1210,7 @@ static HB_Error Load_PairPos1( HB_PairPosFormat1* ppf1, Fail: for ( m = 0; m < n; m++ ) - Free_PairSet( &ps[m], format1, format2, memory ); + Free_PairSet( &ps[m], format1, format2 ); FREE( ps ); return error; @@ -1234,8 +1219,7 @@ Fail: static void Free_PairPos1( HB_PairPosFormat1* ppf1, FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) + FT_UShort format2 ) { FT_UShort n, count; @@ -1248,7 +1232,7 @@ static void Free_PairPos1( HB_PairPosFormat1* ppf1, ps = ppf1->PairSet; for ( n = 0; n < count; n++ ) - Free_PairSet( &ps[n], format1, format2, memory ); + Free_PairSet( &ps[n], format1, format2 ); FREE( ps ); } @@ -1263,7 +1247,6 @@ static HB_Error Load_PairPos2( HB_PairPosFormat2* ppf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort m, n, k, count1, count2; FT_ULong cur_offset, new_offset1, new_offset2, base_offset; @@ -1331,7 +1314,7 @@ static HB_Error Load_PairPos2( HB_PairPosFormat2* ppf2, if ( error ) { if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); + Free_ValueRecord( &c2r[n].Value1, format1 ); goto Fail0; } } @@ -1343,9 +1326,9 @@ static HB_Error Load_PairPos2( HB_PairPosFormat2* ppf2, for ( k = 0; k < n; k++ ) { if ( format1 ) - Free_ValueRecord( &c2r[k].Value1, format1, memory ); + Free_ValueRecord( &c2r[k].Value1, format1 ); if ( format2 ) - Free_ValueRecord( &c2r[k].Value2, format2, memory ); + Free_ValueRecord( &c2r[k].Value2, format2 ); } goto Fail1; } @@ -1360,9 +1343,9 @@ Fail1: for ( n = 0; n < count2; n++ ) { if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); + Free_ValueRecord( &c2r[n].Value1, format1 ); if ( format2 ) - Free_ValueRecord( &c2r[n].Value2, format2, memory ); + Free_ValueRecord( &c2r[n].Value2, format2 ); } FREE( c2r ); @@ -1371,18 +1354,17 @@ Fail1: FREE( c1r ); Fail2: - _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2, memory ); + _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 ); Fail3: - _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1, memory ); + _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 ); return error; } static void Free_PairPos2( HB_PairPosFormat2* ppf2, FT_UShort format1, - FT_UShort format2, - FT_Memory memory ) + FT_UShort format2 ) { FT_UShort m, n, count1, count2; @@ -1403,9 +1385,9 @@ static void Free_PairPos2( HB_PairPosFormat2* ppf2, for ( n = 0; n < count2; n++ ) { if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); + Free_ValueRecord( &c2r[n].Value1, format1 ); if ( format2 ) - Free_ValueRecord( &c2r[n].Value2, format2, memory ); + Free_ValueRecord( &c2r[n].Value2, format2 ); } FREE( c2r ); @@ -1413,8 +1395,8 @@ static void Free_PairPos2( HB_PairPosFormat2* ppf2, FREE( c1r ); - _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2, memory ); - _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1, memory ); + _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 ); + _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 ); } } @@ -1423,7 +1405,6 @@ static HB_Error Load_PairPos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_PairPos* pp = &st->pair; FT_UShort format1, format2; @@ -1470,13 +1451,12 @@ static HB_Error Load_PairPos( HB_GPOS_SubTable* st, return HB_Err_Ok; Fail: - _HB_OPEN_Free_Coverage( &pp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &pp->Coverage ); return error; } -static void Free_PairPos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_PairPos( HB_GPOS_SubTable* st ) { FT_UShort format1, format2; HB_PairPos* pp = &st->pair; @@ -1488,18 +1468,18 @@ static void Free_PairPos( HB_GPOS_SubTable* st, switch ( pp->PosFormat ) { case 1: - Free_PairPos1( &pp->ppf.ppf1, format1, format2, memory ); + Free_PairPos1( &pp->ppf.ppf1, format1, format2 ); break; case 2: - Free_PairPos2( &pp->ppf.ppf2, format1, format2, memory ); + Free_PairPos2( &pp->ppf.ppf2, format1, format2 ); break; default: break; } - _HB_OPEN_Free_Coverage( &pp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &pp->Coverage ); } @@ -1668,7 +1648,6 @@ static HB_Error Load_CursivePos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_CursivePos* cp = &st->cursive; FT_UShort n, m, count; @@ -1749,7 +1728,7 @@ static HB_Error Load_CursivePos( HB_GPOS_SubTable* st, stream ) ) != HB_Err_Ok ) { if ( entry_offset ) - Free_Anchor( &eer[n].EntryAnchor, memory ); + Free_Anchor( &eer[n].EntryAnchor ); goto Fail1; } (void)FILE_Seek( cur_offset ); @@ -1763,20 +1742,19 @@ static HB_Error Load_CursivePos( HB_GPOS_SubTable* st, Fail1: for ( m = 0; m < n; m++ ) { - Free_Anchor( &eer[m].EntryAnchor, memory ); - Free_Anchor( &eer[m].ExitAnchor, memory ); + Free_Anchor( &eer[m].EntryAnchor ); + Free_Anchor( &eer[m].ExitAnchor ); } FREE( eer ); Fail2: - _HB_OPEN_Free_Coverage( &cp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &cp->Coverage ); return error; } -static void Free_CursivePos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_CursivePos( HB_GPOS_SubTable* st ) { FT_UShort n, count; HB_CursivePos* cp = &st->cursive; @@ -1791,14 +1769,14 @@ static void Free_CursivePos( HB_GPOS_SubTable* st, for ( n = 0; n < count; n++ ) { - Free_Anchor( &eer[n].EntryAnchor, memory ); - Free_Anchor( &eer[n].ExitAnchor, memory ); + Free_Anchor( &eer[n].EntryAnchor ); + Free_Anchor( &eer[n].ExitAnchor ); } FREE( eer ); } - _HB_OPEN_Free_Coverage( &cp->Coverage, memory ); + _HB_OPEN_Free_Coverage( &cp->Coverage ); } @@ -2034,7 +2012,6 @@ static HB_Error Load_BaseArray( HB_BaseArray* ba, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort m, n, k, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2096,7 +2073,7 @@ static HB_Error Load_BaseArray( HB_BaseArray* ba, continue; Fail0: for ( k = 0; k < n; k++ ) - Free_Anchor( &ban[k], memory ); + Free_Anchor( &ban[k] ); goto Fail; } @@ -2108,7 +2085,7 @@ Fail: ban = br[k].BaseAnchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &ban[n], memory ); + Free_Anchor( &ban[n] ); FREE( ban ); } @@ -2119,8 +2096,7 @@ Fail: static void Free_BaseArray( HB_BaseArray* ba, - FT_UShort num_classes, - FT_Memory memory ) + FT_UShort num_classes ) { FT_UShort m, n, count; @@ -2138,7 +2114,7 @@ static void Free_BaseArray( HB_BaseArray* ba, ban = br[m].BaseAnchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &ban[n], memory ); + Free_Anchor( &ban[n] ); FREE( ban ); } @@ -2154,7 +2130,6 @@ static HB_Error Load_MarkBasePos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_MarkBasePos* mbp = &st->markbase; FT_ULong cur_offset, new_offset, base_offset; @@ -2222,26 +2197,25 @@ static HB_Error Load_MarkBasePos( HB_GPOS_SubTable* st, return HB_Err_Ok; Fail1: - Free_MarkArray( &mbp->MarkArray, memory ); + Free_MarkArray( &mbp->MarkArray ); Fail2: - _HB_OPEN_Free_Coverage( &mbp->BaseCoverage, memory ); + _HB_OPEN_Free_Coverage( &mbp->BaseCoverage ); Fail3: - _HB_OPEN_Free_Coverage( &mbp->MarkCoverage, memory ); + _HB_OPEN_Free_Coverage( &mbp->MarkCoverage ); return error; } -static void Free_MarkBasePos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_MarkBasePos( HB_GPOS_SubTable* st ) { HB_MarkBasePos* mbp = &st->markbase; - Free_BaseArray( &mbp->BaseArray, mbp->ClassCount, memory ); - Free_MarkArray( &mbp->MarkArray, memory ); - _HB_OPEN_Free_Coverage( &mbp->BaseCoverage, memory ); - _HB_OPEN_Free_Coverage( &mbp->MarkCoverage, memory ); + Free_BaseArray( &mbp->BaseArray, mbp->ClassCount ); + Free_MarkArray( &mbp->MarkArray ); + _HB_OPEN_Free_Coverage( &mbp->BaseCoverage ); + _HB_OPEN_Free_Coverage( &mbp->MarkCoverage ); } @@ -2370,7 +2344,6 @@ static HB_Error Load_LigatureAttach( HB_LigatureAttach* lat, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort m, n, k, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2430,7 +2403,7 @@ static HB_Error Load_LigatureAttach( HB_LigatureAttach* lat, continue; Fail0: for ( k = 0; k < n; k++ ) - Free_Anchor( &lan[k], memory ); + Free_Anchor( &lan[k] ); goto Fail; } @@ -2442,7 +2415,7 @@ Fail: lan = cr[k].LigatureAnchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &lan[n], memory ); + Free_Anchor( &lan[n] ); FREE( lan ); } @@ -2453,8 +2426,7 @@ Fail: static void Free_LigatureAttach( HB_LigatureAttach* lat, - FT_UShort num_classes, - FT_Memory memory ) + FT_UShort num_classes ) { FT_UShort m, n, count; @@ -2472,7 +2444,7 @@ static void Free_LigatureAttach( HB_LigatureAttach* lat, lan = cr[m].LigatureAnchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &lan[n], memory ); + Free_Anchor( &lan[n] ); FREE( lan ); } @@ -2489,7 +2461,6 @@ static HB_Error Load_LigatureArray( HB_LigatureArray* la, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2534,7 +2505,7 @@ static HB_Error Load_LigatureArray( HB_LigatureArray* la, Fail: for ( m = 0; m < n; m++ ) - Free_LigatureAttach( &lat[m], num_classes, memory ); + Free_LigatureAttach( &lat[m], num_classes ); FREE( lat ); return error; @@ -2542,8 +2513,7 @@ Fail: static void Free_LigatureArray( HB_LigatureArray* la, - FT_UShort num_classes, - FT_Memory memory ) + FT_UShort num_classes ) { FT_UShort n, count; @@ -2556,7 +2526,7 @@ static void Free_LigatureArray( HB_LigatureArray* la, lat = la->LigatureAttach; for ( n = 0; n < count; n++ ) - Free_LigatureAttach( &lat[n], num_classes, memory ); + Free_LigatureAttach( &lat[n], num_classes ); FREE( lat ); } @@ -2569,7 +2539,6 @@ static HB_Error Load_MarkLigPos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_MarkLigPos* mlp = &st->marklig; FT_ULong cur_offset, new_offset, base_offset; @@ -2635,26 +2604,25 @@ static HB_Error Load_MarkLigPos( HB_GPOS_SubTable* st, return HB_Err_Ok; Fail1: - Free_MarkArray( &mlp->MarkArray, memory ); + Free_MarkArray( &mlp->MarkArray ); Fail2: - _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage, memory ); + _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage ); Fail3: - _HB_OPEN_Free_Coverage( &mlp->MarkCoverage, memory ); + _HB_OPEN_Free_Coverage( &mlp->MarkCoverage ); return error; } -static void Free_MarkLigPos( HB_GPOS_SubTable* st, - FT_Memory memory) +static void Free_MarkLigPos( HB_GPOS_SubTable* st ) { HB_MarkLigPos* mlp = &st->marklig; - Free_LigatureArray( &mlp->LigatureArray, mlp->ClassCount, memory ); - Free_MarkArray( &mlp->MarkArray, memory ); - _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage, memory ); - _HB_OPEN_Free_Coverage( &mlp->MarkCoverage, memory ); + Free_LigatureArray( &mlp->LigatureArray, mlp->ClassCount ); + Free_MarkArray( &mlp->MarkArray ); + _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage ); + _HB_OPEN_Free_Coverage( &mlp->MarkCoverage ); } @@ -2802,7 +2770,6 @@ static HB_Error Load_Mark2Array( HB_Mark2Array* m2a, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort k, m, n, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2855,7 +2822,7 @@ static HB_Error Load_Mark2Array( HB_Mark2Array* m2a, continue; Fail0: for ( k = 0; k < n; k++ ) - Free_Anchor( &m2an[k], memory ); + Free_Anchor( &m2an[k] ); goto Fail; } @@ -2867,7 +2834,7 @@ Fail: m2an = m2r[k].Mark2Anchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &m2an[n], memory ); + Free_Anchor( &m2an[n] ); FREE( m2an ); } @@ -2878,8 +2845,7 @@ Fail: static void Free_Mark2Array( HB_Mark2Array* m2a, - FT_UShort num_classes, - FT_Memory memory ) + FT_UShort num_classes ) { FT_UShort m, n, count; @@ -2897,7 +2863,7 @@ static void Free_Mark2Array( HB_Mark2Array* m2a, m2an = m2r[m].Mark2Anchor; for ( n = 0; n < num_classes; n++ ) - Free_Anchor( &m2an[n], memory ); + Free_Anchor( &m2an[n] ); FREE( m2an ); } @@ -2913,7 +2879,6 @@ static HB_Error Load_MarkMarkPos( HB_GPOS_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_MarkMarkPos* mmp = &st->markmark; FT_ULong cur_offset, new_offset, base_offset; @@ -2980,26 +2945,25 @@ static HB_Error Load_MarkMarkPos( HB_GPOS_SubTable* st, return HB_Err_Ok; Fail1: - Free_MarkArray( &mmp->Mark1Array, memory ); + Free_MarkArray( &mmp->Mark1Array ); Fail2: - _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage, memory ); + _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage ); Fail3: - _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage, memory ); + _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage ); return error; } -static void Free_MarkMarkPos( HB_GPOS_SubTable* st, - FT_Memory memory) +static void Free_MarkMarkPos( HB_GPOS_SubTable* st ) { HB_MarkMarkPos* mmp = &st->markmark; - Free_Mark2Array( &mmp->Mark2Array, mmp->ClassCount, memory ); - Free_MarkArray( &mmp->Mark1Array, memory ); - _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage, memory ); - _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage, memory ); + Free_Mark2Array( &mmp->Mark2Array, mmp->ClassCount ); + Free_MarkArray( &mmp->Mark1Array ); + _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage ); + _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage ); } @@ -3175,7 +3139,6 @@ static HB_Error Load_PosRule( HB_PosRule* pr, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* i; @@ -3239,8 +3202,7 @@ Fail2: } -static void Free_PosRule( HB_PosRule* pr, - FT_Memory memory ) +static void Free_PosRule( HB_PosRule* pr ) { FREE( pr->PosLookupRecord ); FREE( pr->Input ); @@ -3253,7 +3215,6 @@ static HB_Error Load_PosRuleSet( HB_PosRuleSet* prs, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -3297,15 +3258,14 @@ static HB_Error Load_PosRuleSet( HB_PosRuleSet* prs, Fail: for ( m = 0; m < n; m++ ) - Free_PosRule( &pr[m], memory ); + Free_PosRule( &pr[m] ); FREE( pr ); return error; } -static void Free_PosRuleSet( HB_PosRuleSet* prs, - FT_Memory memory ) +static void Free_PosRuleSet( HB_PosRuleSet* prs ) { FT_UShort n, count; @@ -3318,7 +3278,7 @@ static void Free_PosRuleSet( HB_PosRuleSet* prs, pr = prs->PosRule; for ( n = 0; n < count; n++ ) - Free_PosRule( &pr[n], memory ); + Free_PosRule( &pr[n] ); FREE( pr ); } @@ -3331,7 +3291,6 @@ static HB_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -3388,18 +3347,17 @@ static HB_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1, Fail1: for ( m = 0; m < n; m++ ) - Free_PosRuleSet( &prs[m], memory ); + Free_PosRuleSet( &prs[m] ); FREE( prs ); Fail2: - _HB_OPEN_Free_Coverage( &cpf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &cpf1->Coverage ); return error; } -static void Free_ContextPos1( HB_ContextPosFormat1* cpf1, - FT_Memory memory ) +static void Free_ContextPos1( HB_ContextPosFormat1* cpf1 ) { FT_UShort n, count; @@ -3412,12 +3370,12 @@ static void Free_ContextPos1( HB_ContextPosFormat1* cpf1, prs = cpf1->PosRuleSet; for ( n = 0; n < count; n++ ) - Free_PosRuleSet( &prs[n], memory ); + Free_PosRuleSet( &prs[n] ); FREE( prs ); } - _HB_OPEN_Free_Coverage( &cpf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &cpf1->Coverage ); } @@ -3428,7 +3386,6 @@ static HB_Error Load_PosClassRule( HB_ContextPosFormat2* cpf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -3505,8 +3462,7 @@ Fail2: } -static void Free_PosClassRule( HB_PosClassRule* pcr, - FT_Memory memory ) +static void Free_PosClassRule( HB_PosClassRule* pcr ) { FREE( pcr->PosLookupRecord ); FREE( pcr->Class ); @@ -3520,7 +3476,6 @@ static HB_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -3565,15 +3520,14 @@ static HB_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2, Fail: for ( m = 0; m < n; m++ ) - Free_PosClassRule( &pcr[m], memory ); + Free_PosClassRule( &pcr[m] ); FREE( pcr ); return error; } -static void Free_PosClassSet( HB_PosClassSet* pcs, - FT_Memory memory ) +static void Free_PosClassSet( HB_PosClassSet* pcs ) { FT_UShort n, count; @@ -3586,7 +3540,7 @@ static void Free_PosClassSet( HB_PosClassSet* pcs, pcr = pcs->PosClassRule; for ( n = 0; n < count; n++ ) - Free_PosClassRule( &pcr[n], memory ); + Free_PosClassRule( &pcr[n] ); FREE( pcr ); } @@ -3599,7 +3553,6 @@ static HB_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -3680,21 +3633,20 @@ static HB_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2, Fail1: for ( m = 0; m < n; n++ ) - Free_PosClassSet( &pcs[m], memory ); + Free_PosClassSet( &pcs[m] ); FREE( pcs ); Fail2: - _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef ); Fail3: - _HB_OPEN_Free_Coverage( &cpf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &cpf2->Coverage ); return error; } -static void Free_ContextPos2( HB_ContextPosFormat2* cpf2, - FT_Memory memory ) +static void Free_ContextPos2( HB_ContextPosFormat2* cpf2 ) { FT_UShort n, count; @@ -3707,13 +3659,13 @@ static void Free_ContextPos2( HB_ContextPosFormat2* cpf2, pcs = cpf2->PosClassSet; for ( n = 0; n < count; n++ ) - Free_PosClassSet( &pcs[n], memory ); + Free_PosClassSet( &pcs[n] ); FREE( pcs ); } - _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef, memory ); - _HB_OPEN_Free_Coverage( &cpf2->Coverage, memory ); + _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef ); + _HB_OPEN_Free_Coverage( &cpf2->Coverage ); } @@ -3723,7 +3675,6 @@ static HB_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_ULong cur_offset, new_offset, base_offset; @@ -3794,15 +3745,14 @@ Fail1: Fail2: for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); return error; } -static void Free_ContextPos3( HB_ContextPosFormat3* cpf3, - FT_Memory memory ) +static void Free_ContextPos3( HB_ContextPosFormat3* cpf3 ) { FT_UShort n, count; @@ -3817,7 +3767,7 @@ static void Free_ContextPos3( HB_ContextPosFormat3* cpf3, c = cpf3->Coverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3859,16 +3809,15 @@ static HB_Error Load_ContextPos( HB_GPOS_SubTable* st, } -static void Free_ContextPos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_ContextPos( HB_GPOS_SubTable* st ) { HB_ContextPos* cp = &st->context; switch ( cp->PosFormat ) { - case 1: Free_ContextPos1( &cp->cpf.cpf1, memory ); break; - case 2: Free_ContextPos2( &cp->cpf.cpf2, memory ); break; - case 3: Free_ContextPos3( &cp->cpf.cpf3, memory ); break; + case 1: Free_ContextPos1( &cp->cpf.cpf1 ); break; + case 2: Free_ContextPos2( &cp->cpf.cpf2 ); break; + case 3: Free_ContextPos3( &cp->cpf.cpf3 ); break; default: break; } } @@ -3948,7 +3897,6 @@ static HB_Error Lookup_ContextPos2( GPOS_Instance* gpi, { FT_UShort index, property; HB_Error error; - FT_Memory memory = gpi->face->memory; FT_UShort i, j, k, known_classes; FT_UShort* classes; @@ -4138,7 +4086,6 @@ static HB_Error Load_ChainPosRule( HB_ChainPosRule* cpr, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* b; @@ -4264,8 +4211,7 @@ Fail4: } -static void Free_ChainPosRule( HB_ChainPosRule* cpr, - FT_Memory memory ) +static void Free_ChainPosRule( HB_ChainPosRule* cpr ) { FREE( cpr->PosLookupRecord ); FREE( cpr->Lookahead ); @@ -4280,7 +4226,6 @@ static HB_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -4324,15 +4269,14 @@ static HB_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs, Fail: for ( m = 0; m < n; m++ ) - Free_ChainPosRule( &cpr[m], memory ); + Free_ChainPosRule( &cpr[m] ); FREE( cpr ); return error; } -static void Free_ChainPosRuleSet( HB_ChainPosRuleSet* cprs, - FT_Memory memory ) +static void Free_ChainPosRuleSet( HB_ChainPosRuleSet* cprs ) { FT_UShort n, count; @@ -4345,7 +4289,7 @@ static void Free_ChainPosRuleSet( HB_ChainPosRuleSet* cprs, cpr = cprs->ChainPosRule; for ( n = 0; n < count; n++ ) - Free_ChainPosRule( &cpr[n], memory ); + Free_ChainPosRule( &cpr[n] ); FREE( cpr ); } @@ -4358,7 +4302,6 @@ static HB_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -4415,18 +4358,17 @@ static HB_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1, Fail1: for ( m = 0; m < n; m++ ) - Free_ChainPosRuleSet( &cprs[m], memory ); + Free_ChainPosRuleSet( &cprs[m] ); FREE( cprs ); Fail2: - _HB_OPEN_Free_Coverage( &ccpf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccpf1->Coverage ); return error; } -static void Free_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1, - FT_Memory memory ) +static void Free_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1 ) { FT_UShort n, count; @@ -4439,12 +4381,12 @@ static void Free_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1, cprs = ccpf1->ChainPosRuleSet; for ( n = 0; n < count; n++ ) - Free_ChainPosRuleSet( &cprs[n], memory ); + Free_ChainPosRuleSet( &cprs[n] ); FREE( cprs ); } - _HB_OPEN_Free_Coverage( &ccpf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccpf1->Coverage ); } @@ -4456,7 +4398,6 @@ static HB_Error Load_ChainPosClassRule( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -4613,8 +4554,7 @@ Fail4: } -static void Free_ChainPosClassRule( HB_ChainPosClassRule* cpcr, - FT_Memory memory ) +static void Free_ChainPosClassRule( HB_ChainPosClassRule* cpcr ) { FREE( cpcr->PosLookupRecord ); FREE( cpcr->Lookahead ); @@ -4631,7 +4571,6 @@ static HB_Error Load_ChainPosClassSet( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -4677,15 +4616,14 @@ static HB_Error Load_ChainPosClassSet( Fail: for ( m = 0; m < n; m++ ) - Free_ChainPosClassRule( &cpcr[m], memory ); + Free_ChainPosClassRule( &cpcr[m] ); FREE( cpcr ); return error; } -static void Free_ChainPosClassSet( HB_ChainPosClassSet* cpcs, - FT_Memory memory ) +static void Free_ChainPosClassSet( HB_ChainPosClassSet* cpcs ) { FT_UShort n, count; @@ -4698,45 +4636,19 @@ static void Free_ChainPosClassSet( HB_ChainPosClassSet* cpcs, cpcr = cpcs->ChainPosClassRule; for ( n = 0; n < count; n++ ) - Free_ChainPosClassRule( &cpcr[n], memory ); + Free_ChainPosClassRule( &cpcr[n] ); FREE( cpcr ); } } -static HB_Error GPOS_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd, - FT_UShort limit, - FT_ULong class_offset, - FT_ULong base_offset, - FT_Stream stream ) -{ - HB_Error error; - FT_ULong cur_offset; - - cur_offset = FILE_Pos(); - - if ( class_offset ) - { - if ( !FILE_Seek( class_offset + base_offset ) ) - error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream ); - } - else - error = _HB_OPEN_Load_EmptyClassDefinition ( cd, stream ); - - if (error == HB_Err_Ok) - (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */ - - return error; -} - /* ChainContextPosFormat2 */ static HB_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -4775,15 +4687,15 @@ static HB_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2, FORGET_Frame(); - if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535, backtrack_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail5; - if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, input_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail4; - if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535, lookahead_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail3; @@ -4829,27 +4741,26 @@ static HB_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2, Fail1: for ( m = 0; m < n; m++ ) - Free_ChainPosClassSet( &cpcs[m], memory ); + Free_ChainPosClassSet( &cpcs[m] ); FREE( cpcs ); Fail2: - _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef ); Fail3: - _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef ); Fail4: - _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef ); Fail5: - _HB_OPEN_Free_Coverage( &ccpf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccpf2->Coverage ); return error; } -static void Free_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2, - FT_Memory memory ) +static void Free_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2 ) { FT_UShort n, count; @@ -4862,16 +4773,16 @@ static void Free_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2, cpcs = ccpf2->ChainPosClassSet; for ( n = 0; n < count; n++ ) - Free_ChainPosClassSet( &cpcs[n], memory ); + Free_ChainPosClassSet( &cpcs[n] ); FREE( cpcs ); } - _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef ); + _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef ); - _HB_OPEN_Free_Coverage( &ccpf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccpf2->Coverage ); } @@ -4881,7 +4792,6 @@ static HB_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, nb, ni, nl, m, count; FT_UShort backtrack_count, input_count, lookahead_count; @@ -5027,27 +4937,26 @@ Fail1: Fail2: for ( m = 0; m < nl; m++ ) - _HB_OPEN_Free_Coverage( &l[m], memory ); + _HB_OPEN_Free_Coverage( &l[m] ); FREE( l ); Fail3: for ( m = 0; m < ni; m++ ) - _HB_OPEN_Free_Coverage( &i[m], memory ); + _HB_OPEN_Free_Coverage( &i[m] ); FREE( i ); Fail4: for ( m = 0; m < nb; m++ ) - _HB_OPEN_Free_Coverage( &b[m], memory ); + _HB_OPEN_Free_Coverage( &b[m] ); FREE( b ); return error; } -static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3, - FT_Memory memory ) +static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3 ) { FT_UShort n, count; @@ -5062,7 +4971,7 @@ static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3, c = ccpf3->LookaheadCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -5073,7 +4982,7 @@ static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3, c = ccpf3->InputCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -5084,7 +4993,7 @@ static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3, c = ccpf3->BacktrackCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -5126,16 +5035,15 @@ static HB_Error Load_ChainContextPos( HB_GPOS_SubTable* st, } -static void Free_ChainContextPos( HB_GPOS_SubTable* st, - FT_Memory memory ) +static void Free_ChainContextPos( HB_GPOS_SubTable* st ) { HB_ChainContextPos* ccp = &st->chain; switch ( ccp->PosFormat ) { - case 1: Free_ChainContextPos1( &ccp->ccpf.ccpf1, memory ); break; - case 2: Free_ChainContextPos2( &ccp->ccpf.ccpf2, memory ); break; - case 3: Free_ChainContextPos3( &ccp->ccpf.ccpf3, memory ); break; + case 1: Free_ChainContextPos1( &ccp->ccpf.ccpf1 ); break; + case 2: Free_ChainContextPos2( &ccp->ccpf.ccpf2 ); break; + case 3: Free_ChainContextPos3( &ccp->ccpf.ccpf3 ); break; default: break; } } @@ -5279,7 +5187,6 @@ static HB_Error Lookup_ChainContextPos2( int nesting_level ) { FT_UShort index, property; - FT_Memory memory = gpi->face->memory; HB_Error error; FT_UShort i, j, k; FT_UShort bgc, igc, lgc; @@ -5768,7 +5675,6 @@ HB_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos, FT_ULong** script_tag_list ) { HB_Error error; - FT_Memory memory; FT_UShort n; FT_ULong* stl; @@ -5779,7 +5685,6 @@ HB_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos, if ( !gpos || !script_tag_list ) return HB_Err_Invalid_Argument; - memory = gpos->memory; sl = &gpos->ScriptList; sr = sl->ScriptRecord; @@ -5802,7 +5707,6 @@ HB_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos, FT_ULong** language_tag_list ) { HB_Error error; - FT_Memory memory; FT_UShort n; FT_ULong* ltl; @@ -5815,7 +5719,6 @@ HB_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos, if ( !gpos || !language_tag_list ) return HB_Err_Invalid_Argument; - memory = gpos->memory; sl = &gpos->ScriptList; sr = sl->ScriptRecord; @@ -5849,7 +5752,6 @@ HB_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos, { FT_UShort n; HB_Error error; - FT_Memory memory; FT_ULong* ftl; HB_ScriptList* sl; @@ -5866,7 +5768,6 @@ HB_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos, if ( !gpos || !feature_tag_list ) return HB_Err_Invalid_Argument; - memory = gpos->memory; sl = &gpos->ScriptList; sr = sl->ScriptRecord; @@ -5996,19 +5897,18 @@ HB_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st, void _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st, - FT_Memory memory, FT_UShort lookup_type ) { switch ( lookup_type ) { - case HB_GPOS_LOOKUP_SINGLE: Free_SinglePos ( st, memory ); return; - case HB_GPOS_LOOKUP_PAIR: Free_PairPos ( st, memory ); return; - case HB_GPOS_LOOKUP_CURSIVE: Free_CursivePos ( st, memory ); return; - case HB_GPOS_LOOKUP_MARKBASE: Free_MarkBasePos ( st, memory ); return; - case HB_GPOS_LOOKUP_MARKLIG: Free_MarkLigPos ( st, memory ); return; - case HB_GPOS_LOOKUP_MARKMARK: Free_MarkMarkPos ( st, memory ); return; - case HB_GPOS_LOOKUP_CONTEXT: Free_ContextPos ( st, memory ); return; - case HB_GPOS_LOOKUP_CHAIN: Free_ChainContextPos ( st, memory ); return; - /*case HB_GPOS_LOOKUP_EXTENSION: Free_ExtensionPos ( st, memory ); return;*/ + case HB_GPOS_LOOKUP_SINGLE: Free_SinglePos ( st ); return; + case HB_GPOS_LOOKUP_PAIR: Free_PairPos ( st ); return; + case HB_GPOS_LOOKUP_CURSIVE: Free_CursivePos ( st ); return; + case HB_GPOS_LOOKUP_MARKBASE: Free_MarkBasePos ( st ); return; + case HB_GPOS_LOOKUP_MARKLIG: Free_MarkLigPos ( st ); return; + case HB_GPOS_LOOKUP_MARKMARK: Free_MarkMarkPos ( st ); return; + case HB_GPOS_LOOKUP_CONTEXT: Free_ContextPos ( st ); return; + case HB_GPOS_LOOKUP_CHAIN: Free_ChainContextPos ( st ); return; + /*case HB_GPOS_LOOKUP_EXTENSION: Free_ExtensionPos ( st ); return;*/ default: return; } } @@ -6207,6 +6107,11 @@ HB_Error HB_GPOS_Apply_String( FT_Face face, lookup_count = gpos->LookupList.LookupCount; + if ( gpos->FeatureList.ApplyCount ) + { + memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length); + } + for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ ) { FT_UShort feature_index = gpos->FeatureList.ApplyOrder[i]; @@ -6231,9 +6136,12 @@ HB_Error HB_GPOS_Apply_String( FT_Face face, } } - error = Position_CursiveChain ( buffer ); - if ( error ) - return error; + if ( gpos->FeatureList.ApplyCount ) + { + error = Position_CursiveChain ( buffer ); + if ( error ) + return error; + } return retError; } diff --git a/src/harfbuzz-gpos.h b/src/harfbuzz-gpos.h index 2db7938a7..893f20f2c 100644 --- a/src/harfbuzz-gpos.h +++ b/src/harfbuzz-gpos.h @@ -72,8 +72,6 @@ typedef HB_Error (*HB_MMFunction)(FT_Face face, struct HB_GPOSHeader_ { - FT_Memory memory; - FT_Fixed Version; HB_ScriptList ScriptList; diff --git a/src/harfbuzz-gsub-private.h b/src/harfbuzz-gsub-private.h index bc6d1b445..5096694e4 100644 --- a/src/harfbuzz-gsub-private.h +++ b/src/harfbuzz-gsub-private.h @@ -440,7 +440,6 @@ HB_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st, FT_UShort lookup_type ); void _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st, - FT_Memory memory, FT_UShort lookup_type ); FT_END_HEADER diff --git a/src/harfbuzz-gsub.c b/src/harfbuzz-gsub.c index ab6721a79..16a53850b 100644 --- a/src/harfbuzz-gsub.c +++ b/src/harfbuzz-gsub.c @@ -35,7 +35,6 @@ HB_Error HB_Load_GSUB_Table( FT_Face face, HB_GDEFHeader* gdef ) { FT_Stream stream = face->stream; - FT_Memory memory = face->memory; HB_Error error; FT_ULong cur_offset, new_offset, base_offset; @@ -54,7 +53,6 @@ HB_Error HB_Load_GSUB_Table( FT_Face face, if ( ALLOC ( gsub, sizeof( *gsub ) ) ) return error; - gsub->memory = memory; /* skip version */ @@ -137,13 +135,13 @@ HB_Error HB_Load_GSUB_Table( FT_Face face, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB, memory ); + _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB ); Fail2: - _HB_OPEN_Free_FeatureList( &gsub->FeatureList, memory ); + _HB_OPEN_Free_FeatureList( &gsub->FeatureList ); Fail3: - _HB_OPEN_Free_ScriptList( &gsub->ScriptList, memory ); + _HB_OPEN_Free_ScriptList( &gsub->ScriptList ); Fail4: FREE ( gsub ); @@ -155,11 +153,9 @@ Fail4: HB_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub ) { - FT_Memory memory = gsub->memory; - - _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB, memory ); - _HB_OPEN_Free_FeatureList( &gsub->FeatureList, memory ); - _HB_OPEN_Free_ScriptList( &gsub->ScriptList, memory ); + _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB ); + _HB_OPEN_Free_FeatureList( &gsub->FeatureList ); + _HB_OPEN_Free_ScriptList( &gsub->ScriptList ); FREE( gsub ); @@ -180,7 +176,6 @@ static HB_Error Load_SingleSubst( HB_GSUB_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_SingleSubst* ss = &st->single; FT_UShort n, count; @@ -252,13 +247,12 @@ Fail1: FREE( s ); Fail2: - _HB_OPEN_Free_Coverage( &ss->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ss->Coverage ); return error; } -static void Free_SingleSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_SingleSubst( HB_GSUB_SubTable* st ) { HB_SingleSubst* ss = &st->single; @@ -275,7 +269,7 @@ static void Free_SingleSubst( HB_GSUB_SubTable* st, break; } - _HB_OPEN_Free_Coverage( &ss->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ss->Coverage ); } @@ -344,7 +338,6 @@ static HB_Error Load_Sequence( HB_Sequence* s, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* sub; @@ -382,8 +375,7 @@ static HB_Error Load_Sequence( HB_Sequence* s, } -static void Free_Sequence( HB_Sequence* s, - FT_Memory memory ) +static void Free_Sequence( HB_Sequence* s ) { FREE( s->Substitute ); } @@ -395,7 +387,6 @@ static HB_Error Load_MultipleSubst( HB_GSUB_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_MultipleSubst* ms = &st->multiple; FT_UShort n = 0, m, count; @@ -454,18 +445,17 @@ static HB_Error Load_MultipleSubst( HB_GSUB_SubTable* st, Fail1: for ( m = 0; m < n; m++ ) - Free_Sequence( &s[m], memory ); + Free_Sequence( &s[m] ); FREE( s ); Fail2: - _HB_OPEN_Free_Coverage( &ms->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ms->Coverage ); return error; } -static void Free_MultipleSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_MultipleSubst( HB_GSUB_SubTable* st ) { FT_UShort n, count; HB_MultipleSubst* ms = &st->multiple; @@ -479,12 +469,12 @@ static void Free_MultipleSubst( HB_GSUB_SubTable* st, s = ms->Sequence; for ( n = 0; n < count; n++ ) - Free_Sequence( &s[n], memory ); + Free_Sequence( &s[n] ); FREE( s ); } - _HB_OPEN_Free_Coverage( &ms->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ms->Coverage ); } @@ -549,7 +539,6 @@ static HB_Error Load_AlternateSet( HB_AlternateSet* as, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* a; @@ -584,8 +573,7 @@ static HB_Error Load_AlternateSet( HB_AlternateSet* as, } -static void Free_AlternateSet( HB_AlternateSet* as, - FT_Memory memory ) +static void Free_AlternateSet( HB_AlternateSet* as ) { FREE( as->Alternate ); } @@ -597,7 +585,6 @@ static HB_Error Load_AlternateSubst( HB_GSUB_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_AlternateSubst* as = &st->alternate; FT_UShort n = 0, m, count; @@ -656,18 +643,17 @@ static HB_Error Load_AlternateSubst( HB_GSUB_SubTable* st, Fail1: for ( m = 0; m < n; m++ ) - Free_AlternateSet( &aset[m], memory ); + Free_AlternateSet( &aset[m] ); FREE( aset ); Fail2: - _HB_OPEN_Free_Coverage( &as->Coverage, memory ); + _HB_OPEN_Free_Coverage( &as->Coverage ); return error; } -static void Free_AlternateSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_AlternateSubst( HB_GSUB_SubTable* st ) { FT_UShort n, count; HB_AlternateSubst* as = &st->alternate; @@ -681,12 +667,12 @@ static void Free_AlternateSubst( HB_GSUB_SubTable* st, aset = as->AlternateSet; for ( n = 0; n < count; n++ ) - Free_AlternateSet( &aset[n], memory ); + Free_AlternateSet( &aset[n] ); FREE( aset ); } - _HB_OPEN_Free_Coverage( &as->Coverage, memory ); + _HB_OPEN_Free_Coverage( &as->Coverage ); } @@ -751,7 +737,6 @@ static HB_Error Load_Ligature( HB_Ligature* l, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* c; @@ -789,8 +774,7 @@ static HB_Error Load_Ligature( HB_Ligature* l, } -static void Free_Ligature( HB_Ligature* l, - FT_Memory memory ) +static void Free_Ligature( HB_Ligature* l ) { FREE( l->Component ); } @@ -802,7 +786,6 @@ static HB_Error Load_LigatureSet( HB_LigatureSet* ls, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -846,15 +829,14 @@ static HB_Error Load_LigatureSet( HB_LigatureSet* ls, Fail: for ( m = 0; m < n; m++ ) - Free_Ligature( &l[m], memory ); + Free_Ligature( &l[m] ); FREE( l ); return error; } -static void Free_LigatureSet( HB_LigatureSet* ls, - FT_Memory memory ) +static void Free_LigatureSet( HB_LigatureSet* ls ) { FT_UShort n, count; @@ -867,7 +849,7 @@ static void Free_LigatureSet( HB_LigatureSet* ls, l = ls->Ligature; for ( n = 0; n < count; n++ ) - Free_Ligature( &l[n], memory ); + Free_Ligature( &l[n] ); FREE( l ); } @@ -880,7 +862,6 @@ static HB_Error Load_LigatureSubst( HB_GSUB_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_LigatureSubst* ls = &st->ligature; FT_UShort n = 0, m, count; @@ -939,18 +920,17 @@ static HB_Error Load_LigatureSubst( HB_GSUB_SubTable* st, Fail1: for ( m = 0; m < n; m++ ) - Free_LigatureSet( &lset[m], memory ); + Free_LigatureSet( &lset[m] ); FREE( lset ); Fail2: - _HB_OPEN_Free_Coverage( &ls->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ls->Coverage ); return error; } -static void Free_LigatureSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_LigatureSubst( HB_GSUB_SubTable* st ) { FT_UShort n, count; HB_LigatureSubst* ls = &st->ligature; @@ -964,12 +944,12 @@ static void Free_LigatureSubst( HB_GSUB_SubTable* st, lset = ls->LigatureSet; for ( n = 0; n < count; n++ ) - Free_LigatureSet( &lset[n], memory ); + Free_LigatureSet( &lset[n] ); FREE( lset ); } - _HB_OPEN_Free_Coverage( &ls->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ls->Coverage ); } @@ -1165,7 +1145,6 @@ static HB_Error Load_SubRule( HB_SubRule* sr, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* i; @@ -1229,8 +1208,7 @@ Fail2: } -static void Free_SubRule( HB_SubRule* sr, - FT_Memory memory ) +static void Free_SubRule( HB_SubRule* sr ) { FREE( sr->SubstLookupRecord ); FREE( sr->Input ); @@ -1243,7 +1221,6 @@ static HB_Error Load_SubRuleSet( HB_SubRuleSet* srs, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1287,15 +1264,14 @@ static HB_Error Load_SubRuleSet( HB_SubRuleSet* srs, Fail: for ( m = 0; m < n; m++ ) - Free_SubRule( &sr[m], memory ); + Free_SubRule( &sr[m] ); FREE( sr ); return error; } -static void Free_SubRuleSet( HB_SubRuleSet* srs, - FT_Memory memory ) +static void Free_SubRuleSet( HB_SubRuleSet* srs ) { FT_UShort n, count; @@ -1308,7 +1284,7 @@ static void Free_SubRuleSet( HB_SubRuleSet* srs, sr = srs->SubRule; for ( n = 0; n < count; n++ ) - Free_SubRule( &sr[n], memory ); + Free_SubRule( &sr[n] ); FREE( sr ); } @@ -1321,7 +1297,6 @@ static HB_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1378,18 +1353,17 @@ static HB_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1, Fail1: for ( m = 0; m < n; m++ ) - Free_SubRuleSet( &srs[m], memory ); + Free_SubRuleSet( &srs[m] ); FREE( srs ); Fail2: - _HB_OPEN_Free_Coverage( &csf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &csf1->Coverage ); return error; } -static void Free_ContextSubst1( HB_ContextSubstFormat1* csf1, - FT_Memory memory ) +static void Free_ContextSubst1( HB_ContextSubstFormat1* csf1 ) { FT_UShort n, count; @@ -1402,12 +1376,12 @@ static void Free_ContextSubst1( HB_ContextSubstFormat1* csf1, srs = csf1->SubRuleSet; for ( n = 0; n < count; n++ ) - Free_SubRuleSet( &srs[n], memory ); + Free_SubRuleSet( &srs[n] ); FREE( srs ); } - _HB_OPEN_Free_Coverage( &csf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &csf1->Coverage ); } @@ -1418,7 +1392,6 @@ static HB_Error Load_SubClassRule( HB_ContextSubstFormat2* csf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -1494,8 +1467,7 @@ Fail2: } -static void Free_SubClassRule( HB_SubClassRule* scr, - FT_Memory memory ) +static void Free_SubClassRule( HB_SubClassRule* scr ) { FREE( scr->SubstLookupRecord ); FREE( scr->Class ); @@ -1509,7 +1481,6 @@ static HB_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1554,15 +1525,14 @@ static HB_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2, Fail: for ( m = 0; m < n; m++ ) - Free_SubClassRule( &scr[m], memory ); + Free_SubClassRule( &scr[m] ); FREE( scr ); return error; } -static void Free_SubClassSet( HB_SubClassSet* scs, - FT_Memory memory ) +static void Free_SubClassSet( HB_SubClassSet* scs ) { FT_UShort n, count; @@ -1575,7 +1545,7 @@ static void Free_SubClassSet( HB_SubClassSet* scs, scr = scs->SubClassRule; for ( n = 0; n < count; n++ ) - Free_SubClassRule( &scr[n], memory ); + Free_SubClassRule( &scr[n] ); FREE( scr ); } @@ -1588,7 +1558,6 @@ static HB_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1669,21 +1638,20 @@ static HB_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2, Fail1: for ( m = 0; m < n; m++ ) - Free_SubClassSet( &scs[m], memory ); + Free_SubClassSet( &scs[m] ); FREE( scs ); Fail2: - _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef ); Fail3: - _HB_OPEN_Free_Coverage( &csf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &csf2->Coverage ); return error; } -static void Free_ContextSubst2( HB_ContextSubstFormat2* csf2, - FT_Memory memory ) +static void Free_ContextSubst2( HB_ContextSubstFormat2* csf2 ) { FT_UShort n, count; @@ -1696,13 +1664,13 @@ static void Free_ContextSubst2( HB_ContextSubstFormat2* csf2, scs = csf2->SubClassSet; for ( n = 0; n < count; n++ ) - Free_SubClassSet( &scs[n], memory ); + Free_SubClassSet( &scs[n] ); FREE( scs ); } - _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef, memory ); - _HB_OPEN_Free_Coverage( &csf2->Coverage, memory ); + _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef ); + _HB_OPEN_Free_Coverage( &csf2->Coverage ); } @@ -1712,7 +1680,6 @@ static HB_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -1784,15 +1751,14 @@ Fail1: Fail2: for ( m = 0; m < n; m++ ) - _HB_OPEN_Free_Coverage( &c[m], memory ); + _HB_OPEN_Free_Coverage( &c[m] ); FREE( c ); return error; } -static void Free_ContextSubst3( HB_ContextSubstFormat3* csf3, - FT_Memory memory ) +static void Free_ContextSubst3( HB_ContextSubstFormat3* csf3 ) { FT_UShort n, count; @@ -1807,7 +1773,7 @@ static void Free_ContextSubst3( HB_ContextSubstFormat3* csf3, c = csf3->Coverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -1842,16 +1808,15 @@ static HB_Error Load_ContextSubst( HB_GSUB_SubTable* st, } -static void Free_ContextSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_ContextSubst( HB_GSUB_SubTable* st ) { HB_ContextSubst* cs = &st->context; switch ( cs->SubstFormat ) { - case 1: Free_ContextSubst1( &cs->csf.csf1, memory ); break; - case 2: Free_ContextSubst2( &cs->csf.csf2, memory ); break; - case 3: Free_ContextSubst3( &cs->csf.csf3, memory ); break; + case 1: Free_ContextSubst1( &cs->csf.csf1 ); break; + case 2: Free_ContextSubst2( &cs->csf.csf2 ); break; + case 3: Free_ContextSubst3( &cs->csf.csf3 ); break; default: break; } } @@ -1929,7 +1894,6 @@ static HB_Error Lookup_ContextSubst2( HB_GSUBHeader* gsub, { FT_UShort index, property; HB_Error error; - FT_Memory memory = gsub->memory; FT_UShort i, j, k, known_classes; FT_UShort* classes; @@ -2107,7 +2071,6 @@ static HB_Error Load_ChainSubRule( HB_ChainSubRule* csr, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* b; @@ -2233,8 +2196,7 @@ Fail4: } -static void Free_ChainSubRule( HB_ChainSubRule* csr, - FT_Memory memory ) +static void Free_ChainSubRule( HB_ChainSubRule* csr ) { FREE( csr->SubstLookupRecord ); FREE( csr->Lookahead ); @@ -2249,7 +2211,6 @@ static HB_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2293,15 +2254,14 @@ static HB_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs, Fail: for ( m = 0; m < n; m++ ) - Free_ChainSubRule( &csr[m], memory ); + Free_ChainSubRule( &csr[m] ); FREE( csr ); return error; } -static void Free_ChainSubRuleSet( HB_ChainSubRuleSet* csrs, - FT_Memory memory ) +static void Free_ChainSubRuleSet( HB_ChainSubRuleSet* csrs ) { FT_UShort n, count; @@ -2314,7 +2274,7 @@ static void Free_ChainSubRuleSet( HB_ChainSubRuleSet* csrs, csr = csrs->ChainSubRule; for ( n = 0; n < count; n++ ) - Free_ChainSubRule( &csr[n], memory ); + Free_ChainSubRule( &csr[n] ); FREE( csr ); } @@ -2328,7 +2288,6 @@ static HB_Error Load_ChainContextSubst1( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2385,18 +2344,17 @@ static HB_Error Load_ChainContextSubst1( Fail1: for ( m = 0; m < n; m++ ) - Free_ChainSubRuleSet( &csrs[m], memory ); + Free_ChainSubRuleSet( &csrs[m] ); FREE( csrs ); Fail2: - _HB_OPEN_Free_Coverage( &ccsf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccsf1->Coverage ); return error; } -static void Free_ChainContextSubst1( HB_ChainContextSubstFormat1* ccsf1, - FT_Memory memory ) +static void Free_ChainContextSubst1( HB_ChainContextSubstFormat1* ccsf1 ) { FT_UShort n, count; @@ -2409,12 +2367,12 @@ static void Free_ChainContextSubst1( HB_ChainContextSubstFormat1* ccsf1, csrs = ccsf1->ChainSubRuleSet; for ( n = 0; n < count; n++ ) - Free_ChainSubRuleSet( &csrs[n], memory ); + Free_ChainSubRuleSet( &csrs[n] ); FREE( csrs ); } - _HB_OPEN_Free_Coverage( &ccsf1->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccsf1->Coverage ); } @@ -2426,7 +2384,6 @@ static HB_Error Load_ChainSubClassRule( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -2584,8 +2541,7 @@ Fail4: } -static void Free_ChainSubClassRule( HB_ChainSubClassRule* cscr, - FT_Memory memory ) +static void Free_ChainSubClassRule( HB_ChainSubClassRule* cscr ) { FREE( cscr->SubstLookupRecord ); FREE( cscr->Lookahead ); @@ -2602,7 +2558,6 @@ static HB_Error Load_ChainSubClassSet( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2648,15 +2603,14 @@ static HB_Error Load_ChainSubClassSet( Fail: for ( m = 0; m < n; m++ ) - Free_ChainSubClassRule( &cscr[m], memory ); + Free_ChainSubClassRule( &cscr[m] ); FREE( cscr ); return error; } -static void Free_ChainSubClassSet( HB_ChainSubClassSet* cscs, - FT_Memory memory ) +static void Free_ChainSubClassSet( HB_ChainSubClassSet* cscs ) { FT_UShort n, count; @@ -2669,37 +2623,12 @@ static void Free_ChainSubClassSet( HB_ChainSubClassSet* cscs, cscr = cscs->ChainSubClassRule; for ( n = 0; n < count; n++ ) - Free_ChainSubClassRule( &cscr[n], memory ); + Free_ChainSubClassRule( &cscr[n] ); FREE( cscr ); } } -static HB_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd, - FT_UShort limit, - FT_ULong class_offset, - FT_ULong base_offset, - FT_Stream stream ) -{ - HB_Error error; - FT_ULong cur_offset; - - cur_offset = FILE_Pos(); - - if ( class_offset ) - { - if ( !FILE_Seek( class_offset + base_offset ) ) - error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream ); - } - else - error = _HB_OPEN_Load_EmptyClassDefinition ( cd, stream ); - - if (error == HB_Err_Ok) - (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */ - - return error; -} - /* ChainContextSubstFormat2 */ @@ -2708,7 +2637,6 @@ static HB_Error Load_ChainContextSubst2( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n = 0, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -2747,16 +2675,16 @@ static HB_Error Load_ChainContextSubst2( FORGET_Frame(); - if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535, backtrack_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail5; - if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count, input_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail4; - if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535, + if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535, lookahead_offset, base_offset, stream ) ) != HB_Err_Ok ) goto Fail3; @@ -2802,27 +2730,26 @@ static HB_Error Load_ChainContextSubst2( Fail1: for ( m = 0; m < n; m++ ) - Free_ChainSubClassSet( &cscs[m], memory ); + Free_ChainSubClassSet( &cscs[m] ); FREE( cscs ); Fail2: - _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef ); Fail3: - _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef ); Fail4: - _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef ); Fail5: - _HB_OPEN_Free_Coverage( &ccsf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccsf2->Coverage ); return error; } -static void Free_ChainContextSubst2( HB_ChainContextSubstFormat2* ccsf2, - FT_Memory memory ) +static void Free_ChainContextSubst2( HB_ChainContextSubstFormat2* ccsf2 ) { FT_UShort n, count; @@ -2835,16 +2762,16 @@ static void Free_ChainContextSubst2( HB_ChainContextSubstFormat2* ccsf2, cscs = ccsf2->ChainSubClassSet; for ( n = 0; n < count; n++ ) - Free_ChainSubClassSet( &cscs[n], memory ); + Free_ChainSubClassSet( &cscs[n] ); FREE( cscs ); } - _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef, memory ); - _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef ); + _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef ); - _HB_OPEN_Free_Coverage( &ccsf2->Coverage, memory ); + _HB_OPEN_Free_Coverage( &ccsf2->Coverage ); } @@ -2855,7 +2782,6 @@ static HB_Error Load_ChainContextSubst3( FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, nb = 0, ni =0, nl = 0, m, count; FT_UShort backtrack_count, input_count, lookahead_count; @@ -3002,27 +2928,26 @@ Fail1: Fail2: for ( m = 0; m < nl; m++ ) - _HB_OPEN_Free_Coverage( &l[m], memory ); + _HB_OPEN_Free_Coverage( &l[m] ); FREE( l ); Fail3: for ( m = 0; m < ni; m++ ) - _HB_OPEN_Free_Coverage( &i[m], memory ); + _HB_OPEN_Free_Coverage( &i[m] ); FREE( i ); Fail4: for ( m = 0; m < nb; m++ ) - _HB_OPEN_Free_Coverage( &b[m], memory ); + _HB_OPEN_Free_Coverage( &b[m] ); FREE( b ); return error; } -static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3, - FT_Memory memory ) +static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3 ) { FT_UShort n, count; @@ -3037,7 +2962,7 @@ static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3, c = ccsf3->LookaheadCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3048,7 +2973,7 @@ static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3, c = ccsf3->InputCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3059,7 +2984,7 @@ static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3, c = ccsf3->BacktrackCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3092,15 +3017,14 @@ static HB_Error Load_ChainContextSubst( HB_GSUB_SubTable* st, } -static void Free_ChainContextSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_ChainContextSubst( HB_GSUB_SubTable* st ) { HB_ChainContextSubst* ccs = &st->chain; switch ( ccs->SubstFormat ) { - case 1: Free_ChainContextSubst1( &ccs->ccsf.ccsf1, memory ); break; - case 2: Free_ChainContextSubst2( &ccs->ccsf.ccsf2, memory ); break; - case 3: Free_ChainContextSubst3( &ccs->ccsf.ccsf3, memory ); break; + case 1: Free_ChainContextSubst1( &ccs->ccsf.ccsf1 ); break; + case 2: Free_ChainContextSubst2( &ccs->ccsf.ccsf2 ); break; + case 3: Free_ChainContextSubst3( &ccs->ccsf.ccsf3 ); break; default: break; } } @@ -3241,7 +3165,6 @@ static HB_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub, int nesting_level ) { FT_UShort index, property; - FT_Memory memory; HB_Error error; FT_UShort i, j, k; FT_UShort bgc, igc, lgc; @@ -3263,7 +3186,6 @@ static HB_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub, gdef = gsub->gdef; - memory = gsub->memory; if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) return error; @@ -3566,7 +3488,6 @@ static HB_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; HB_ReverseChainContextSubst* rccs = &st->reverse; FT_UShort m, count; @@ -3704,31 +3625,30 @@ Fail1: Fail2: for ( m = 0; m < nl; m++ ) - _HB_OPEN_Free_Coverage( &l[m], memory ); + _HB_OPEN_Free_Coverage( &l[m] ); FREE( l ); Fail3: for ( m = 0; m < nb; m++ ) - _HB_OPEN_Free_Coverage( &b[m], memory ); + _HB_OPEN_Free_Coverage( &b[m] ); FREE( b ); Fail4: - _HB_OPEN_Free_Coverage( &rccs->Coverage, memory ); + _HB_OPEN_Free_Coverage( &rccs->Coverage ); return error; } -static void Free_ReverseChainContextSubst( HB_GSUB_SubTable* st, - FT_Memory memory ) +static void Free_ReverseChainContextSubst( HB_GSUB_SubTable* st ) { FT_UShort n, count; HB_ReverseChainContextSubst* rccs = &st->reverse; HB_Coverage* c; - _HB_OPEN_Free_Coverage( &rccs->Coverage, memory ); + _HB_OPEN_Free_Coverage( &rccs->Coverage ); if ( rccs->LookaheadCoverage ) { @@ -3736,7 +3656,7 @@ static void Free_ReverseChainContextSubst( HB_GSUB_SubTable* st, c = rccs->LookaheadCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3747,7 +3667,7 @@ static void Free_ReverseChainContextSubst( HB_GSUB_SubTable* st, c = rccs->BacktrackCoverage; for ( n = 0; n < count; n++ ) - _HB_OPEN_Free_Coverage( &c[n], memory ); + _HB_OPEN_Free_Coverage( &c[n] ); FREE( c ); } @@ -3995,7 +3915,6 @@ HB_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub, { FT_UShort n; HB_Error error; - FT_Memory memory; FT_ULong* stl; HB_ScriptList* sl; @@ -4005,8 +3924,6 @@ HB_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub, if ( !gsub || !script_tag_list ) return HB_Err_Invalid_Argument; - memory = gsub->memory; - sl = &gsub->ScriptList; sr = sl->ScriptRecord; @@ -4030,7 +3947,6 @@ HB_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub, { FT_UShort n; HB_Error error; - FT_Memory memory; FT_ULong* ltl; HB_ScriptList* sl; @@ -4042,8 +3958,6 @@ HB_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub, if ( !gsub || !language_tag_list ) return HB_Err_Invalid_Argument; - memory = gsub->memory; - sl = &gsub->ScriptList; sr = sl->ScriptRecord; @@ -4077,7 +3991,6 @@ HB_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub, { FT_UShort n; HB_Error error; - FT_Memory memory; FT_ULong* ftl; HB_ScriptList* sl; @@ -4094,8 +4007,6 @@ HB_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub, if ( !gsub || !feature_tag_list ) return HB_Err_Invalid_Argument; - memory = gsub->memory; - sl = &gsub->ScriptList; sr = sl->ScriptRecord; @@ -4220,19 +4131,18 @@ HB_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st, void _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st, - FT_Memory memory, FT_UShort lookup_type ) { switch ( lookup_type ) { - case HB_GSUB_LOOKUP_SINGLE: Free_SingleSubst ( st, memory ); return; - case HB_GSUB_LOOKUP_MULTIPLE: Free_MultipleSubst ( st, memory ); return; - case HB_GSUB_LOOKUP_ALTERNATE: Free_AlternateSubst ( st, memory ); return; - case HB_GSUB_LOOKUP_LIGATURE: Free_LigatureSubst ( st, memory ); return; - case HB_GSUB_LOOKUP_CONTEXT: Free_ContextSubst ( st, memory ); return; - case HB_GSUB_LOOKUP_CHAIN: Free_ChainContextSubst ( st, memory ); return; - /*case HB_GSUB_LOOKUP_EXTENSION: Free_ExtensionSubst ( st, memory ); return;*/ - case HB_GSUB_LOOKUP_REVERSE_CHAIN: Free_ReverseChainContextSubst ( st, memory ); return; - default: return; + case HB_GSUB_LOOKUP_SINGLE: Free_SingleSubst ( st ); return; + case HB_GSUB_LOOKUP_MULTIPLE: Free_MultipleSubst ( st ); return; + case HB_GSUB_LOOKUP_ALTERNATE: Free_AlternateSubst ( st ); return; + case HB_GSUB_LOOKUP_LIGATURE: Free_LigatureSubst ( st ); return; + case HB_GSUB_LOOKUP_CONTEXT: Free_ContextSubst ( st ); return; + case HB_GSUB_LOOKUP_CHAIN: Free_ChainContextSubst ( st ); return; + /*case HB_GSUB_LOOKUP_EXTENSION: Free_ExtensionSubst ( st ); return;*/ + case HB_GSUB_LOOKUP_REVERSE_CHAIN: Free_ReverseChainContextSubst ( st ); return; + default: return; }; } diff --git a/src/harfbuzz-gsub.h b/src/harfbuzz-gsub.h index 3c72981ea..129671b45 100644 --- a/src/harfbuzz-gsub.h +++ b/src/harfbuzz-gsub.h @@ -50,8 +50,6 @@ typedef FT_UShort (*HB_AltFunction)(FT_ULong pos, struct HB_GSUBHeader_ { - FT_Memory memory; - FT_ULong offset; FT_Fixed Version; diff --git a/src/harfbuzz-open-private.h b/src/harfbuzz-open-private.h index 03d232dec..2e2149a0b 100644 --- a/src/harfbuzz-open-private.h +++ b/src/harfbuzz-open-private.h @@ -43,25 +43,22 @@ HB_Error _HB_OPEN_Load_Coverage( HB_Coverage* c, HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd, FT_UShort limit, FT_Stream input ); -HB_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd, - FT_Stream input ); +HB_Error _HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd, + FT_UShort limit, + FT_ULong class_offset, + FT_ULong base_offset, + FT_Stream stream ); HB_Error _HB_OPEN_Load_Device( HB_Device* d, FT_Stream input ); -void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl, - FT_Memory memory ); -void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl, - FT_Memory memory ); +void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl ); +void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl ); void _HB_OPEN_Free_LookupList( HB_LookupList* ll, - HB_Type type, - FT_Memory memory ); + HB_Type type ); -void _HB_OPEN_Free_Coverage( HB_Coverage* c, - FT_Memory memory ); -void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd, - FT_Memory memory ); -void _HB_OPEN_Free_Device( HB_Device* d, - FT_Memory memory ); +void _HB_OPEN_Free_Coverage( HB_Coverage* c ); +void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd ); +void _HB_OPEN_Free_Device( HB_Device* d ); diff --git a/src/harfbuzz-open.c b/src/harfbuzz-open.c index 2aebb5ac4..defcd1b60 100644 --- a/src/harfbuzz-open.c +++ b/src/harfbuzz-open.c @@ -25,7 +25,6 @@ static HB_Error Load_LangSys( HB_LangSys* ls, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; FT_UShort* fi; @@ -61,8 +60,7 @@ static HB_Error Load_LangSys( HB_LangSys* ls, } -static void Free_LangSys( HB_LangSys* ls, - FT_Memory memory ) +static void Free_LangSys( HB_LangSys* ls ) { FREE( ls->FeatureIndex ); } @@ -74,7 +72,6 @@ static HB_Error Load_Script( HB_Script* s, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -153,25 +150,24 @@ static HB_Error Load_Script( HB_Script* s, Fail1: for ( m = 0; m < n; m++ ) - Free_LangSys( &lsr[m].LangSys, memory ); + Free_LangSys( &lsr[m].LangSys ); FREE( s->LangSysRecord ); Fail2: - Free_LangSys( &s->DefaultLangSys, memory ); + Free_LangSys( &s->DefaultLangSys ); return error; } -static void Free_Script( HB_Script* s, - FT_Memory memory ) +static void Free_Script( HB_Script* s ) { FT_UShort n, count; HB_LangSysRecord* lsr; - Free_LangSys( &s->DefaultLangSys, memory ); + Free_LangSys( &s->DefaultLangSys ); if ( s->LangSysRecord ) { @@ -179,7 +175,7 @@ static void Free_Script( HB_Script* s, lsr = s->LangSysRecord; for ( n = 0; n < count; n++ ) - Free_LangSys( &lsr[n].LangSys, memory ); + Free_LangSys( &lsr[n].LangSys ); FREE( lsr ); } @@ -192,7 +188,6 @@ HB_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, script_count; FT_ULong cur_offset, new_offset, base_offset; @@ -256,15 +251,14 @@ HB_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl, Fail: for ( n = 0; n < sl->ScriptCount; n++ ) - Free_Script( &sr[n].Script, memory ); + Free_Script( &sr[n].Script ); FREE( sl->ScriptRecord ); return error; } -void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl, - FT_Memory memory ) +void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl ) { FT_UShort n, count; @@ -277,7 +271,7 @@ void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl, sr = sl->ScriptRecord; for ( n = 0; n < count; n++ ) - Free_Script( &sr[n].Script, memory ); + Free_Script( &sr[n].Script ); FREE( sr ); } @@ -296,7 +290,6 @@ static HB_Error Load_Feature( HB_Feature* f, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -333,8 +326,7 @@ static HB_Error Load_Feature( HB_Feature* f, } -static void Free_Feature( HB_Feature* f, - FT_Memory memory ) +static void Free_Feature( HB_Feature* f ) { FREE( f->LookupListIndex ); } @@ -346,7 +338,6 @@ HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -395,7 +386,7 @@ HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl, Fail1: for ( m = 0; m < n; m++ ) - Free_Feature( &fr[m].Feature, memory ); + Free_Feature( &fr[m].Feature ); FREE( fl->ApplyOrder ); @@ -406,8 +397,7 @@ Fail2: } -void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl, - FT_Memory memory) +void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl ) { FT_UShort n, count; @@ -420,7 +410,7 @@ void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl, fr = fl->FeatureRecord; for ( n = 0; n < count; n++ ) - Free_Feature( &fr[n].Feature, memory ); + Free_Feature( &fr[n].Feature ); FREE( fr ); } @@ -454,13 +444,12 @@ static HB_Error Load_SubTable( HB_SubTable* st, static void Free_SubTable( HB_SubTable* st, HB_Type table_type, - FT_UShort lookup_type, - FT_Memory memory ) + FT_UShort lookup_type ) { if ( table_type == HB_Type_GSUB ) - _HB_GSUB_Free_SubTable ( &st->st.gsub, memory, lookup_type ); + _HB_GSUB_Free_SubTable ( &st->st.gsub, lookup_type ); else - _HB_GPOS_Free_SubTable ( &st->st.gpos, memory, lookup_type ); + _HB_GPOS_Free_SubTable ( &st->st.gpos, lookup_type ); } @@ -471,7 +460,6 @@ static HB_Error Load_Lookup( HB_Lookup* l, HB_Type type ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -539,7 +527,7 @@ static HB_Error Load_Lookup( HB_Lookup* l, Fail: for ( m = 0; m < n; m++ ) - Free_SubTable( &st[m], type, l->LookupType, memory ); + Free_SubTable( &st[m], type, l->LookupType ); FREE( l->SubTable ); return error; @@ -547,8 +535,7 @@ Fail: static void Free_Lookup( HB_Lookup* l, - HB_Type type, - FT_Memory memory) + HB_Type type ) { FT_UShort n, count; @@ -561,7 +548,7 @@ static void Free_Lookup( HB_Lookup* l, st = l->SubTable; for ( n = 0; n < count; n++ ) - Free_SubTable( &st[n], type, l->LookupType, memory ); + Free_SubTable( &st[n], type, l->LookupType ); FREE( st ); } @@ -575,7 +562,6 @@ HB_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll, HB_Type type ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, m, count; FT_ULong cur_offset, new_offset, base_offset; @@ -623,7 +609,7 @@ Fail1: FREE( ll->Properties ); for ( m = 0; m < n; m++ ) - Free_Lookup( &l[m], type, memory ); + Free_Lookup( &l[m], type ); Fail2: FREE( ll->Lookup ); @@ -632,8 +618,7 @@ Fail2: void _HB_OPEN_Free_LookupList( HB_LookupList* ll, - HB_Type type, - FT_Memory memory ) + HB_Type type ) { FT_UShort n, count; @@ -648,7 +633,7 @@ void _HB_OPEN_Free_LookupList( HB_LookupList* ll, l = ll->Lookup; for ( n = 0; n < count; n++ ) - Free_Lookup( &l[n], type, memory ); + Free_Lookup( &l[n], type ); FREE( l ); } @@ -667,7 +652,6 @@ static HB_Error Load_Coverage1( HB_CoverageFormat1* cf1, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -703,8 +687,7 @@ static HB_Error Load_Coverage1( HB_CoverageFormat1* cf1, } -static void Free_Coverage1( HB_CoverageFormat1* cf1, - FT_Memory memory) +static void Free_Coverage1( HB_CoverageFormat1* cf1 ) { FREE( cf1->GlyphArray ); } @@ -716,7 +699,6 @@ static HB_Error Load_Coverage2( HB_CoverageFormat2* cf2, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -766,8 +748,7 @@ Fail: } -static void Free_Coverage2( HB_CoverageFormat2* cf2, - FT_Memory memory ) +static void Free_Coverage2( HB_CoverageFormat2* cf2 ) { FREE( cf2->RangeRecord ); } @@ -796,13 +777,12 @@ HB_Error _HB_OPEN_Load_Coverage( HB_Coverage* c, } -void _HB_OPEN_Free_Coverage( HB_Coverage* c, - FT_Memory memory ) +void _HB_OPEN_Free_Coverage( HB_Coverage* c ) { switch ( c->CoverageFormat ) { - case 1: Free_Coverage1( &c->cf.cf1, memory ); break; - case 2: Free_Coverage2( &c->cf.cf2, memory ); break; + case 1: Free_Coverage1( &c->cf.cf1 ); break; + case 2: Free_Coverage2( &c->cf.cf2 ); break; default: break; } } @@ -936,7 +916,6 @@ static HB_Error Load_ClassDef1( HB_ClassDefinition* cd, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -994,8 +973,7 @@ Fail: } -static void Free_ClassDef1( HB_ClassDefFormat1* cdf1, - FT_Memory memory ) +static void Free_ClassDef1( HB_ClassDefFormat1* cdf1 ) { FREE( cdf1->ClassValueArray ); } @@ -1008,7 +986,6 @@ static HB_Error Load_ClassDef2( HB_ClassDefinition* cd, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -1074,8 +1051,7 @@ Fail: } -static void Free_ClassDef2( HB_ClassDefFormat2* cdf2, - FT_Memory memory ) +static void Free_ClassDef2( HB_ClassDefFormat2* cdf2 ) { FREE( cdf2->ClassRangeRecord ); } @@ -1088,8 +1064,6 @@ HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; - if ( ALLOC_ARRAY( cd->Defined, limit, FT_Bool ) ) return error; @@ -1121,12 +1095,9 @@ Fail: } -HB_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd, - FT_Stream stream ) +static HB_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd ) { HB_Error error; - FT_Memory memory = stream->memory; - if ( ALLOC_ARRAY( cd->Defined, 1, FT_Bool ) ) return error; @@ -1144,8 +1115,32 @@ Fail: return error; } -void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd, - FT_Memory memory ) +HB_Error _HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd, + FT_UShort limit, + FT_ULong class_offset, + FT_ULong base_offset, + FT_Stream stream ) +{ + HB_Error error; + FT_ULong cur_offset; + + cur_offset = FILE_Pos(); + + if ( class_offset ) + { + if ( !FILE_Seek( class_offset + base_offset ) ) + error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream ); + } + else + error = _HB_OPEN_Load_EmptyClassDefinition ( cd ); + + if (error == HB_Err_Ok) + (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */ + + return error; +} + +void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd ) { if ( !cd->loaded ) return; @@ -1154,9 +1149,9 @@ void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd, switch ( cd->ClassFormat ) { - case 1: Free_ClassDef1( &cd->cd.cd1, memory ); break; - case 2: Free_ClassDef2( &cd->cd.cd2, memory ); break; - default: break; + case 1: Free_ClassDef1( &cd->cd.cd1 ); break; + case 2: Free_ClassDef2( &cd->cd.cd2 ); break; + default: break; } } @@ -1285,7 +1280,6 @@ HB_Error _HB_OPEN_Load_Device( HB_Device* d, FT_Stream stream ) { HB_Error error; - FT_Memory memory = stream->memory; FT_UShort n, count; @@ -1337,8 +1331,7 @@ HB_Error _HB_OPEN_Load_Device( HB_Device* d, } -void _HB_OPEN_Free_Device( HB_Device* d, - FT_Memory memory ) +void _HB_OPEN_Free_Device( HB_Device* d ) { FREE( d->DeltaValue ); }