freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] 2 commits: [bdf,pcf] Avoid some memory


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] 2 commits: [bdf,pcf] Avoid some memory zeroing.
Date: Mon, 26 Apr 2021 07:52:36 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

6 changed files:

Changes:

  • ChangeLog
    1
    +2021-04-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
    
    2
    +
    
    3
    +	[base] Avoid some memory zeroing.
    
    4
    +
    
    5
    +	* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Use FT_QNEW_ARRAY.
    
    6
    +	* src/base/ftsnames.c (FT_Get_Sfnt_{Name,LangTag}): Ditto.
    
    7
    +
    
    8
    +2021-04-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
    
    9
    +
    
    10
    +	[bdf,pcf] Avoid some memory zeroing.
    
    11
    +
    
    12
    +	* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties, pcf_load_font):
    
    13
    +	Tweak memory macros.
    
    14
    +	* src/bdf/bdfdrivr.c (BDF_Face_Init): Ditto.
    
    15
    +	* src/bdf/bdflib.c (_bdf_readstreami, bdf_create_property,
    
    16
    +	_bdf_parse_glyphs, _bdf_parse_start): Ditto.
    
    17
    +	(_bdf_add_property): Do not handle zero size.
    
    18
    +
    
    1 19
     2021-04-25  Issam E. Maghni  <issam.e.maghni@mailbox.org>
    
    2 20
     
    
    3 21
     	* builds/meson/process_ftoption_h.py: Add LF at EOF.
    

  • src/base/ftrfork.c
    ... ... @@ -299,7 +299,7 @@
    299 299
                             j, ref[j].res_id, ref[j].offset ));
    
    300 300
             }
    
    301 301
     
    
    302
    -        if ( FT_NEW_ARRAY( offsets_internal, *count ) )
    
    302
    +        if ( FT_QNEW_ARRAY( offsets_internal, *count ) )
    
    303 303
               goto Exit;
    
    304 304
     
    
    305 305
             /* XXX: duplicated reference ID,
    

  • src/base/ftsnames.c
    ... ... @@ -65,7 +65,7 @@
    65 65
               FT_Stream  stream = face->stream;
    
    66 66
     
    
    67 67
     
    
    68
    -          if ( FT_NEW_ARRAY  ( entry->string, entry->stringLength ) ||
    
    68
    +          if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
    
    69 69
                    FT_STREAM_SEEK( entry->stringOffset )                ||
    
    70 70
                    FT_STREAM_READ( entry->string, entry->stringLength ) )
    
    71 71
               {
    
    ... ... @@ -121,7 +121,7 @@
    121 121
               FT_Stream  stream = face->stream;
    
    122 122
     
    
    123 123
     
    
    124
    -          if ( FT_NEW_ARRAY  ( entry->string, entry->stringLength ) ||
    
    124
    +          if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
    
    125 125
                    FT_STREAM_SEEK( entry->stringOffset )                ||
    
    126 126
                    FT_STREAM_READ( entry->string, entry->stringLength ) )
    
    127 127
               {
    

  • src/bdf/bdfdrivr.c
    ... ... @@ -442,7 +442,7 @@ THE SOFTWARE.
    442 442
           bdfface->num_glyphs = (FT_Long)( font->glyphs_size + 1 );
    
    443 443
     
    
    444 444
           bdfface->num_fixed_sizes = 1;
    
    445
    -      if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
    
    445
    +      if ( FT_NEW( bdfface->available_sizes ) )
    
    446 446
             goto Exit;
    
    447 447
     
    
    448 448
           {
    
    ... ... @@ -451,8 +451,6 @@ THE SOFTWARE.
    451 451
             long             value;
    
    452 452
     
    
    453 453
     
    
    454
    -        FT_ZERO( bsize );
    
    455
    -
    
    456 454
             /* sanity checks */
    
    457 455
             if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
    
    458 456
             {
    

  • src/bdf/bdflib.c
    ... ... @@ -538,7 +538,7 @@
    538 538
         /* initial size and allocation of the input buffer */
    
    539 539
         buf_size = 1024;
    
    540 540
     
    
    541
    -    if ( FT_NEW_ARRAY( buf, buf_size ) )
    
    541
    +    if ( FT_QALLOC( buf, buf_size ) )
    
    542 542
           goto Exit;
    
    543 543
     
    
    544 544
         cb      = callback;
    
    ... ... @@ -599,7 +599,7 @@
    599 599
               }
    
    600 600
     
    
    601 601
               new_size = buf_size * 2;
    
    602
    -          if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) )
    
    602
    +          if ( FT_QREALLOC( buf, buf_size, new_size ) )
    
    603 603
                 goto Exit;
    
    604 604
     
    
    605 605
               cursor   = (ptrdiff_t)buf_size;
    
    ... ... @@ -850,13 +850,12 @@
    850 850
           goto Exit;
    
    851 851
     
    
    852 852
         p = font->user_props + font->nuser_props;
    
    853
    -    FT_ZERO( p );
    
    854 853
     
    
    855 854
         n = ft_strlen( name ) + 1;
    
    856 855
         if ( n > FT_ULONG_MAX )
    
    857 856
           return FT_THROW( Invalid_Argument );
    
    858 857
     
    
    859
    -    if ( FT_NEW_ARRAY( p->name, n ) )
    
    858
    +    if ( FT_QALLOC( p->name, n ) )
    
    860 859
           goto Exit;
    
    861 860
     
    
    862 861
         FT_MEM_COPY( (char *)p->name, name, n );
    
    ... ... @@ -1159,21 +1158,12 @@
    1159 1158
         /* Allocate another property if this is overflowing. */
    
    1160 1159
         if ( font->props_used == font->props_size )
    
    1161 1160
         {
    
    1162
    -      if ( font->props_size == 0 )
    
    1163
    -      {
    
    1164
    -        if ( FT_NEW_ARRAY( font->props, 1 ) )
    
    1165
    -          goto Exit;
    
    1166
    -      }
    
    1167
    -      else
    
    1168
    -      {
    
    1169
    -        if ( FT_RENEW_ARRAY( font->props,
    
    1170
    -                             font->props_size,
    
    1171
    -                             font->props_size + 1 ) )
    
    1172
    -          goto Exit;
    
    1173
    -      }
    
    1161
    +      if ( FT_RENEW_ARRAY( font->props,
    
    1162
    +                           font->props_size,
    
    1163
    +                           font->props_size + 1 ) )
    
    1164
    +        goto Exit;
    
    1174 1165
     
    
    1175 1166
           fp = font->props + font->props_size;
    
    1176
    -      FT_ZERO( fp );
    
    1177 1167
           font->props_size++;
    
    1178 1168
         }
    
    1179 1169
     
    
    ... ... @@ -1438,7 +1428,7 @@
    1438 1428
             goto Exit;
    
    1439 1429
           }
    
    1440 1430
     
    
    1441
    -      if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) )
    
    1431
    +      if ( FT_QALLOC( p->glyph_name, slen + 1 ) )
    
    1442 1432
             goto Exit;
    
    1443 1433
     
    
    1444 1434
           FT_MEM_COPY( p->glyph_name, s, slen + 1 );
    
    ... ... @@ -1735,7 +1725,7 @@
    1735 1725
           else
    
    1736 1726
             glyph->bytes = (unsigned short)bitmap_size;
    
    1737 1727
     
    
    1738
    -      if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) )
    
    1728
    +      if ( FT_ALLOC( glyph->bitmap, glyph->bytes ) )
    
    1739 1729
             goto Exit;
    
    1740 1730
     
    
    1741 1731
           p->row    = 0;
    
    ... ... @@ -2055,7 +2045,7 @@
    2055 2045
           /* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
    
    2056 2046
           FT_FREE( p->font->name );
    
    2057 2047
     
    
    2058
    -      if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
    
    2048
    +      if ( FT_QALLOC( p->font->name, slen + 1 ) )
    
    2059 2049
             goto Exit;
    
    2060 2050
           FT_MEM_COPY( p->font->name, s, slen + 1 );
    
    2061 2051
     
    

  • src/pcf/pcfread.c
    ... ... @@ -127,7 +127,7 @@ THE SOFTWARE.
    127 127
           toc->count = FT_MIN( stream->size >> 4, 9 );
    
    128 128
         }
    
    129 129
     
    
    130
    -    if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
    
    130
    +    if ( FT_QNEW_ARRAY( face->toc.tables, toc->count ) )
    
    131 131
           return error;
    
    132 132
     
    
    133 133
         tables = face->toc.tables;
    
    ... ... @@ -540,7 +540,7 @@ THE SOFTWARE.
    540 540
     
    
    541 541
         face->nprops = (int)nprops;
    
    542 542
     
    
    543
    -    if ( FT_NEW_ARRAY( props, nprops ) )
    
    543
    +    if ( FT_QNEW_ARRAY( props, nprops ) )
    
    544 544
           goto Bail;
    
    545 545
     
    
    546 546
         for ( i = 0; i < nprops; i++ )
    
    ... ... @@ -607,12 +607,11 @@ THE SOFTWARE.
    607 607
         }
    
    608 608
     
    
    609 609
         /* allocate one more byte so that we have a final null byte */
    
    610
    -    if ( FT_NEW_ARRAY( strings, string_size + 1 ) )
    
    610
    +    if ( FT_QALLOC( strings, string_size + 1 )  ||
    
    611
    +         FT_STREAM_READ( strings, string_size ) )
    
    611 612
           goto Bail;
    
    612 613
     
    
    613
    -    error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );
    
    614
    -    if ( error )
    
    615
    -      goto Bail;
    
    614
    +    strings[string_size] = '\0';
    
    616 615
     
    
    617 616
         if ( FT_NEW_ARRAY( properties, nprops ) )
    
    618 617
           goto Bail;
    
    ... ... @@ -1532,7 +1531,7 @@ THE SOFTWARE.
    1532 1531
               {
    
    1533 1532
                 l += ft_strlen( foundry_prop->value.atom ) + 1;
    
    1534 1533
     
    
    1535
    -            if ( FT_NEW_ARRAY( root->family_name, l ) )
    
    1534
    +            if ( FT_QALLOC( root->family_name, l ) )
    
    1536 1535
                   goto Exit;
    
    1537 1536
     
    
    1538 1537
                 ft_strcpy( root->family_name, foundry_prop->value.atom );
    
    ... ... @@ -1541,7 +1540,7 @@ THE SOFTWARE.
    1541 1540
               }
    
    1542 1541
               else
    
    1543 1542
               {
    
    1544
    -            if ( FT_NEW_ARRAY( root->family_name, l ) )
    
    1543
    +            if ( FT_QALLOC( root->family_name, l ) )
    
    1545 1544
                   goto Exit;
    
    1546 1545
     
    
    1547 1546
                 ft_strcpy( root->family_name, prop->value.atom );
    
    ... ... @@ -1565,7 +1564,7 @@ THE SOFTWARE.
    1565 1564
           root->num_glyphs = (FT_Long)face->nmetrics;
    
    1566 1565
     
    
    1567 1566
           root->num_fixed_sizes = 1;
    
    1568
    -      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
    
    1567
    +      if ( FT_NEW( root->available_sizes ) )
    
    1569 1568
             goto Exit;
    
    1570 1569
     
    
    1571 1570
           {
    
    ... ... @@ -1573,8 +1572,6 @@ THE SOFTWARE.
    1573 1572
             FT_Short         resolution_x = 0, resolution_y = 0;
    
    1574 1573
     
    
    1575 1574
     
    
    1576
    -        FT_ZERO( bsize );
    
    1577
    -
    
    1578 1575
             /* for simplicity, we take absolute values of integer properties */
    
    1579 1576
     
    
    1580 1577
     #if 0
    


  • reply via email to

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