summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2023-03-20 16:53:51 -0400
committerAlexei Podtelezhnikov <apodtele@gmail.com>2023-03-20 16:53:51 -0400
commit4d8db130ea4342317581bab65fc96365ce806b77 (patch)
tree3ab5c82afb8ca7437a7fee5860381f00c9c9ee1a
parent4f0a55d15ed1c9af267ed8223cc2f04307a3d656 (diff)
downloadfreetype2-4d8db130ea4342317581bab65fc96365ce806b77.tar.gz
[cff] Simplify `t2_strings` management in the old engine.
* src/cff/cffparse.c (cff_parser_run): Allocate the charstring buffers and the list nodes together so that they can be freed at once. (finalize_t2_strings): Removed as no longer needed. (cff_parser_done): Updated.
-rw-r--r--src/cff/cffparse.c56
-rw-r--r--src/cff/cffparse.h9
2 files changed, 7 insertions, 58 deletions
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 35d4fead2..a31f085d9 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -73,26 +73,6 @@
}
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- static void
- finalize_t2_strings( FT_Memory memory,
- void* data,
- void* user )
- {
- FT_UNUSED( user );
-
- if ( data )
- {
- CFF_T2_String t2 = (CFF_T2_String)data;
-
-
- FT_FREE( t2->start );
- FT_FREE( data );
- }
- }
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
FT_LOCAL_DEF( void )
cff_parser_done( CFF_Parser parser )
{
@@ -102,10 +82,7 @@
FT_FREE( parser->stack );
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_List_Finalize( &parser->t2_strings,
- finalize_t2_strings,
- memory,
- NULL );
+ FT_List_Finalize( &parser->t2_strings, NULL, memory, NULL );
#endif
}
@@ -1224,9 +1201,6 @@
FT_ULong charstring_len;
FT_Fixed* stack;
- FT_ListNode node;
- CFF_T2_String t2;
- FT_PtrDist t2_size;
FT_Byte* q;
@@ -1268,30 +1242,16 @@
/* Now copy the stack data in the temporary decoder object, */
/* converting it back to charstring number representations */
/* (this is ugly, I know). */
- if ( FT_NEW( node ) )
- goto Exit;
-
- FT_List_Add( &parser->t2_strings, node );
-
- if ( FT_NEW( t2 ) )
- goto Exit;
-
- node->data = t2;
-
- /* `5' is the conservative upper bound of required bytes per stack */
- /* element. */
-
- t2_size = 5 * ( decoder.top - decoder.stack );
-
- if ( FT_QALLOC( q, t2_size ) )
+ /* The maximum required size is 5 bytes per stack element. */
+ if ( FT_QALLOC( q, 2 * sizeof ( FT_ListNode ) +
+ 5 * ( decoder.top - decoder.stack ) ) )
goto Exit;
- t2->start = q;
- t2->limit = q + t2_size;
+ FT_List_Add( &parser->t2_strings, (FT_ListNode)q );
- stack = decoder.stack;
+ q += 2 * sizeof ( FT_ListNode );
- while ( stack < decoder.top )
+ for ( stack = decoder.stack; stack < decoder.top; stack++ )
{
FT_Long num = *stack;
@@ -1332,8 +1292,6 @@
*q++ = (FT_Byte)( num & 0xFF );
}
}
-
- stack++;
}
}
#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
diff --git a/src/cff/cffparse.h b/src/cff/cffparse.h
index 58d59fa4a..b6378a8e8 100644
--- a/src/cff/cffparse.h
+++ b/src/cff/cffparse.h
@@ -133,15 +133,6 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- typedef struct CFF_T2_String_
- {
- FT_Byte* start;
- FT_Byte* limit;
-
- } CFF_T2_StringRec, *CFF_T2_String;
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
#endif /* CFFPARSE_H_ */