[sfnt] Avoid some memory zeroing.

* src/sfnt/sfobjs.c (sfnt_open_font, sfnt_init_face,
tt_name_ascii_from_{utf16,other}): Tweak allocaton macros.
* src/sfnt/ttload.c (tt_face_load_name): Ditto.
This commit is contained in:
Alexei Podtelezhnikov 2021-05-01 12:46:44 -04:00
parent b8968d666e
commit dc42f826af
3 changed files with 21 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2021-05-01 Alexei Podtelezhnikov <apodtele@gmail.com>
[sfnt] Avoid some memory zeroing.
* src/sfnt/sfobjs.c (sfnt_open_font, sfnt_init_face,
tt_name_ascii_from_{utf16,other}): Tweak allocaton macros.
* src/sfnt/ttload.c (tt_face_load_name): Ditto.
2021-05-01 Alexei Podtelezhnikov <apodtele@gmail.com>
* src/sfnt/ttpost.c (load_format_{20,25}): Tweak allocaton macros.

View File

@ -65,7 +65,7 @@
len = (FT_UInt)entry->stringLength / 2;
if ( FT_NEW_ARRAY( string, len + 1 ) )
if ( FT_QNEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
@ -100,7 +100,7 @@
len = (FT_UInt)entry->stringLength;
if ( FT_NEW_ARRAY( string, len + 1 ) )
if ( FT_QNEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
@ -446,7 +446,7 @@
return FT_THROW( Array_Too_Large );
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
if ( FT_QNEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
@ -464,7 +464,7 @@
face->ttc_header.version = 1 << 16;
face->ttc_header.count = 1;
if ( FT_NEW( face->ttc_header.offsets ) )
if ( FT_QNEW( face->ttc_header.offsets ) )
return error;
face->ttc_header.offsets[0] = offset;
@ -643,8 +643,8 @@
*/
if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
!( FT_ALLOC( default_values, num_axes * 4 ) ||
FT_ALLOC( instance_values, num_axes * 4 ) ) )
!( FT_QALLOC( default_values, num_axes * 4 ) ||
FT_QALLOC( instance_values, num_axes * 4 ) ) )
{
/* the current stream position is 16 bytes after the table start */
FT_ULong array_start = FT_STREAM_POS() - 16 + offset;

View File

@ -917,8 +917,8 @@
storage_start += 2 + 4 * table->numLangTagRecords;
/* allocate language tag records array */
if ( FT_NEW_ARRAY( table->langTags, table->numLangTagRecords ) ||
FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
if ( FT_QNEW_ARRAY( table->langTags, table->numLangTagRecords ) ||
FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
goto Exit;
/* load language tags */
@ -948,8 +948,8 @@
}
/* allocate name records array */
if ( FT_NEW_ARRAY( table->names, table->numNameRecords ) ||
FT_FRAME_ENTER( table->numNameRecords * 12 ) )
if ( FT_QNEW_ARRAY( table->names, table->numNameRecords ) ||
FT_FRAME_ENTER( table->numNameRecords * 12 ) )
goto Exit;
/* load name records */
@ -993,9 +993,9 @@
/* reduce array size to the actually used elements */
count = (FT_UInt)( entry - table->names );
(void)FT_RENEW_ARRAY( table->names,
table->numNameRecords,
count );
(void)FT_QRENEW_ARRAY( table->names,
table->numNameRecords,
count );
table->numNameRecords = count;
}