[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 35d4fea..a31f085 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 58d59fa..b6378a8 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_ */