From dc42f826af89e758d160c8855eadb53eb6815fa1 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Sat, 1 May 2021 12:46:44 -0400 Subject: [PATCH] [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. --- ChangeLog | 8 ++++++++ src/sfnt/sfobjs.c | 12 ++++++------ src/sfnt/ttload.c | 14 +++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1114a78e7..a9edaf553 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-05-01 Alexei Podtelezhnikov + + [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 * src/sfnt/ttpost.c (load_format_{20,25}): Tweak allocaton macros. diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index b88dbb71a..7dba3a719 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -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; diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 84a3b2b54..ec66edcb6 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -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; }