freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] [cff] Simplify `t2_strings` management


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [cff] Simplify `t2_strings` management in the old engine.
Date: Mon, 20 Mar 2023 21:04:54 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 4d8db130
    by Alexei Podtelezhnikov at 2023-03-20T16:53:51-04:00
    [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.
    

2 changed files:

Changes:

  • src/cff/cffparse.c
    ... ... @@ -73,26 +73,6 @@
    73 73
       }
    
    74 74
     
    
    75 75
     
    
    76
    -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
    
    77
    -  static void
    
    78
    -  finalize_t2_strings( FT_Memory  memory,
    
    79
    -                       void*      data,
    
    80
    -                       void*      user )
    
    81
    -  {
    
    82
    -    FT_UNUSED( user );
    
    83
    -
    
    84
    -    if ( data )
    
    85
    -    {
    
    86
    -      CFF_T2_String  t2 = (CFF_T2_String)data;
    
    87
    -
    
    88
    -
    
    89
    -      FT_FREE( t2->start );
    
    90
    -      FT_FREE( data );
    
    91
    -    }
    
    92
    -  }
    
    93
    -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
    
    94
    -
    
    95
    -
    
    96 76
       FT_LOCAL_DEF( void )
    
    97 77
       cff_parser_done( CFF_Parser  parser )
    
    98 78
       {
    
    ... ... @@ -102,10 +82,7 @@
    102 82
         FT_FREE( parser->stack );
    
    103 83
     
    
    104 84
     #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
    
    105
    -    FT_List_Finalize( &parser->t2_strings,
    
    106
    -                      finalize_t2_strings,
    
    107
    -                      memory,
    
    108
    -                      NULL );
    
    85
    +    FT_List_Finalize( &parser->t2_strings, NULL, memory, NULL );
    
    109 86
     #endif
    
    110 87
       }
    
    111 88
     
    
    ... ... @@ -1224,9 +1201,6 @@
    1224 1201
             FT_ULong     charstring_len;
    
    1225 1202
     
    
    1226 1203
             FT_Fixed*      stack;
    
    1227
    -        FT_ListNode    node;
    
    1228
    -        CFF_T2_String  t2;
    
    1229
    -        FT_PtrDist     t2_size;
    
    1230 1204
             FT_Byte*       q;
    
    1231 1205
     
    
    1232 1206
     
    
    ... ... @@ -1268,30 +1242,16 @@
    1268 1242
             /* Now copy the stack data in the temporary decoder object,    */
    
    1269 1243
             /* converting it back to charstring number representations     */
    
    1270 1244
             /* (this is ugly, I know).                                     */
    
    1271
    -        if ( FT_NEW( node ) )
    
    1272
    -          goto Exit;
    
    1273
    -
    
    1274
    -        FT_List_Add( &parser->t2_strings, node );
    
    1275
    -
    
    1276
    -        if ( FT_NEW( t2 ) )
    
    1277
    -          goto Exit;
    
    1278
    -
    
    1279
    -        node->data = t2;
    
    1280
    -
    
    1281
    -        /* `5' is the conservative upper bound of required bytes per stack */
    
    1282
    -        /* element.                                                        */
    
    1283
    -
    
    1284
    -        t2_size = 5 * ( decoder.top - decoder.stack );
    
    1285
    -
    
    1286
    -        if ( FT_QALLOC( q, t2_size ) )
    
    1245
    +        /* The maximum required size is 5 bytes per stack element.     */
    
    1246
    +        if ( FT_QALLOC( q, 2 * sizeof ( FT_ListNode ) +
    
    1247
    +                           5 * ( decoder.top - decoder.stack ) ) )
    
    1287 1248
               goto Exit;
    
    1288 1249
     
    
    1289
    -        t2->start = q;
    
    1290
    -        t2->limit = q + t2_size;
    
    1250
    +        FT_List_Add( &parser->t2_strings, (FT_ListNode)q );
    
    1291 1251
     
    
    1292
    -        stack = decoder.stack;
    
    1252
    +        q += 2 * sizeof ( FT_ListNode );
    
    1293 1253
     
    
    1294
    -        while ( stack < decoder.top )
    
    1254
    +        for ( stack = decoder.stack; stack < decoder.top; stack++ )
    
    1295 1255
             {
    
    1296 1256
               FT_Long  num = *stack;
    
    1297 1257
     
    
    ... ... @@ -1332,8 +1292,6 @@
    1332 1292
                   *q++ = (FT_Byte)( num & 0xFF );
    
    1333 1293
                 }
    
    1334 1294
               }
    
    1335
    -
    
    1336
    -          stack++;
    
    1337 1295
             }
    
    1338 1296
           }
    
    1339 1297
     #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
    

  • src/cff/cffparse.h
    ... ... @@ -133,15 +133,6 @@ FT_BEGIN_HEADER
    133 133
     FT_END_HEADER
    
    134 134
     
    
    135 135
     
    
    136
    -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
    
    137
    -  typedef struct  CFF_T2_String_
    
    138
    -  {
    
    139
    -    FT_Byte*  start;
    
    140
    -    FT_Byte*  limit;
    
    141
    -
    
    142
    -  } CFF_T2_StringRec, *CFF_T2_String;
    
    143
    -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
    
    144
    -
    
    145 136
     #endif /* CFFPARSE_H_ */
    
    146 137
     
    
    147 138
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]