Commit dc42f826af89e758d160c8855eadb53eb6815fa1

Alexei Podtelezhnikov 2021-05-01T12:46:44

[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.

diff --git a/ChangeLog b/ChangeLog
index 1114a78..a9edaf5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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.
 
 2021-05-01  Alexei Podtelezhnikov  <apodtele@gmail.com>
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index b88dbb7..7dba3a7 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 84a3b2b..ec66edc 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;
     }