freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [truetype] Reduce allocation scope.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [truetype] Reduce allocation scope.
Date: Thu, 23 May 2024 03:42:55 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 9ff4153c
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-22T23:38:34-04:00
    [truetype] Reduce allocation scope.
    
    * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Reduce scope
    of `points_org` and 'points_out`.
    

1 changed file:

Changes:

  • src/truetype/ttgxvar.c
    ... ... @@ -4079,10 +4079,6 @@
    4079 4079
         FT_UInt    glyph_index = loader->glyph_index;
    
    4080 4080
         FT_UInt    n_points    = (FT_UInt)outline->n_points + 4;
    
    4081 4081
     
    
    4082
    -    FT_Vector*  points_org = NULL;  /* coordinates in 16.16 format */
    
    4083
    -    FT_Vector*  points_out = NULL;  /* coordinates in 16.16 format */
    
    4084
    -    FT_Bool*    has_delta  = NULL;
    
    4085
    -
    
    4086 4082
         FT_ULong  glyph_start;
    
    4087 4083
     
    
    4088 4084
         FT_UInt   tupleCount;
    
    ... ... @@ -4129,17 +4125,12 @@
    4129 4125
           return FT_Err_Ok;
    
    4130 4126
         }
    
    4131 4127
     
    
    4132
    -    if ( FT_NEW_ARRAY( points_org, n_points ) ||
    
    4133
    -         FT_NEW_ARRAY( points_out, n_points ) ||
    
    4134
    -         FT_NEW_ARRAY( has_delta, n_points )  )
    
    4135
    -      goto Fail1;
    
    4136
    -
    
    4137 4128
         dataSize = blend->glyphoffsets[glyph_index + 1] -
    
    4138 4129
                      blend->glyphoffsets[glyph_index];
    
    4139 4130
     
    
    4140 4131
         if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
    
    4141 4132
              FT_FRAME_ENTER( dataSize )                         )
    
    4142
    -      goto Fail1;
    
    4133
    +      return error;
    
    4143 4134
     
    
    4144 4135
         glyph_start = FT_Stream_FTell( stream );
    
    4145 4136
     
    
    ... ... @@ -4189,12 +4180,6 @@
    4189 4180
              FT_NEW_ARRAY( point_deltas_y, n_points ) )
    
    4190 4181
           goto Fail3;
    
    4191 4182
     
    
    4192
    -    for ( j = 0; j < n_points; j++ )
    
    4193
    -    {
    
    4194
    -      points_org[j].x = FT_intToFixed( outline->points[j].x );
    
    4195
    -      points_org[j].y = FT_intToFixed( outline->points[j].y );
    
    4196
    -    }
    
    4197
    -
    
    4198 4183
         for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
    
    4199 4184
         {
    
    4200 4185
           FT_UInt   tupleDataSize;
    
    ... ... @@ -4324,19 +4309,30 @@
    4324 4309
     
    
    4325 4310
           else
    
    4326 4311
           {
    
    4312
    +        FT_Vector*  points_org = NULL;  /* coordinates in 16.16 format */
    
    4313
    +        FT_Vector*  points_out = NULL;  /* coordinates in 16.16 format */
    
    4314
    +        FT_Bool*    has_delta  = NULL;
    
    4315
    +
    
    4327 4316
     #ifdef FT_DEBUG_LEVEL_TRACE
    
    4328 4317
             int  count = 0;
    
    4329 4318
     #endif
    
    4330 4319
     
    
    4331 4320
     
    
    4332
    -        /* we have to interpolate the missing deltas similar to the */
    
    4333
    -        /* IUP bytecode instruction                                 */
    
    4321
    +        /* note that `has_delta` is set to FALSE, zeroed out */
    
    4322
    +        if ( FT_QNEW_ARRAY( points_org, n_points ) ||
    
    4323
    +             FT_QNEW_ARRAY( points_out, n_points ) ||
    
    4324
    +             FT_NEW_ARRAY( has_delta, n_points )   )
    
    4325
    +          goto Fail4;
    
    4326
    +
    
    4334 4327
             for ( j = 0; j < n_points; j++ )
    
    4335 4328
             {
    
    4336
    -          has_delta[j]  = FALSE;
    
    4337
    -          points_out[j] = points_org[j];
    
    4329
    +          points_org[j].x = FT_intToFixed( outline->points[j].x );
    
    4330
    +          points_org[j].y = FT_intToFixed( outline->points[j].y );
    
    4338 4331
             }
    
    4332
    +        FT_ARRAY_COPY( points_out, points_org, n_points );
    
    4339 4333
     
    
    4334
    +        /* we have to interpolate the missing deltas similar to the */
    
    4335
    +        /* IUP bytecode instruction                                 */
    
    4340 4336
             for ( j = 0; j < point_count; j++ )
    
    4341 4337
             {
    
    4342 4338
               FT_UShort  idx = points[j];
    
    ... ... @@ -4394,6 +4390,10 @@
    4394 4390
             if ( !count )
    
    4395 4391
               FT_TRACE7(( "      none\n" ));
    
    4396 4392
     #endif
    
    4393
    +      Fail4:
    
    4394
    +        FT_FREE( points_org );
    
    4395
    +        FT_FREE( points_out );
    
    4396
    +        FT_FREE( has_delta );
    
    4397 4397
           }
    
    4398 4398
     
    
    4399 4399
           if ( localpoints != ALL_POINTS )
    
    ... ... @@ -4466,11 +4466,6 @@
    4466 4466
     
    
    4467 4467
         FT_FRAME_EXIT();
    
    4468 4468
     
    
    4469
    -  Fail1:
    
    4470
    -    FT_FREE( points_org );
    
    4471
    -    FT_FREE( points_out );
    
    4472
    -    FT_FREE( has_delta );
    
    4473
    -
    
    4474 4469
         return error;
    
    4475 4470
       }
    
    4476 4471
     
    


  • reply via email to

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