Commit 8750e843df27a0798d1f998be609d326d53b1c3f

Alexei Podtelezhnikov 2021-04-26T17:21:51

[cff] Avoid some memory zeroing. * src/cff/cffparse.c (cff_parser_init): Tweak memory macro. * src/cff/cffload.c (cff_index_load_offsets, cff_index_get_pointers, cff_charset_load, cff_vstore_load): Ditto.

diff --git a/ChangeLog b/ChangeLog
index d366fb6..6726962 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2021-04-26  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
+	[cff] Avoid some memory zeroing.
+
+	* src/cff/cffparse.c (cff_parser_init): Tweak memory macro.
+	* src/cff/cffload.c (cff_index_load_offsets, cff_index_get_pointers,
+	cff_charset_load, cff_vstore_load): Ditto.
+
+2021-04-26  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
 	[pfr] Avoid some memory zeroing.
 
 	* src/pfr/pfrobjs.c (pfr_face_init) : Tweak memory macro.
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 23cba50..9ad00d8 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -356,9 +356,9 @@
 
       data_size = (FT_ULong)( idx->count + 1 ) * offsize;
 
-      if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) ||
-           FT_STREAM_SEEK( idx->start + idx->hdr_size ) ||
-           FT_FRAME_ENTER( data_size )                  )
+      if ( FT_QNEW_ARRAY( idx->offsets, idx->count + 1 ) ||
+           FT_STREAM_SEEK( idx->start + idx->hdr_size )  ||
+           FT_FRAME_ENTER( data_size )                   )
         goto Exit;
 
       poff   = idx->offsets;
@@ -427,7 +427,7 @@
     new_size = idx->data_size + idx->count;
 
     if ( idx->count > 0                                &&
-         !FT_NEW_ARRAY( tbl, idx->count + 1 )          &&
+         !FT_QNEW_ARRAY( tbl, idx->count + 1 )         &&
          ( !pool || !FT_ALLOC( new_bytes, new_size ) ) )
     {
       FT_ULong  n, cur_offset;
@@ -931,7 +931,7 @@
         goto Exit;
 
       /* Allocate memory for sids. */
-      if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
+      if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
         goto Exit;
 
       /* assign the .notdef glyph */
@@ -1024,7 +1024,7 @@
         }
 
         /* Allocate memory for sids. */
-        if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
+        if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
           goto Exit;
 
         /* Copy the predefined charset into the allocated memory. */
@@ -1042,7 +1042,7 @@
         }
 
         /* Allocate memory for sids. */
-        if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
+        if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
           goto Exit;
 
         /* Copy the predefined charset into the allocated memory.     */
@@ -1060,7 +1060,7 @@
         }
 
         /* Allocate memory for sids. */
-        if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
+        if ( FT_QNEW_ARRAY( charset->sids, num_glyphs ) )
           goto Exit;
 
         /* Copy the predefined charset into the allocated memory.     */
@@ -1086,7 +1086,6 @@
       FT_FREE( charset->cids );
       charset->format = 0;
       charset->offset = 0;
-      charset->sids   = 0;
     }
 
     return error;
@@ -1168,7 +1167,7 @@
 
       /* make temporary copy of item variation data offsets; */
       /* we'll parse region list first, then come back       */
-      if ( FT_NEW_ARRAY( dataOffsetArray, vstore->dataCount ) )
+      if ( FT_QNEW_ARRAY( dataOffsetArray, vstore->dataCount ) )
         goto Exit;
 
       for ( i = 0; i < vstore->dataCount; i++ )
@@ -1183,7 +1182,7 @@
            FT_READ_USHORT( vstore->regionCount )         )
         goto Exit;
 
-      if ( FT_NEW_ARRAY( vstore->varRegionList, vstore->regionCount ) )
+      if ( FT_QNEW_ARRAY( vstore->varRegionList, vstore->regionCount ) )
         goto Exit;
 
       for ( i = 0; i < vstore->regionCount; i++ )
@@ -1191,7 +1190,7 @@
         CFF_VarRegion*  region = &vstore->varRegionList[i];
 
 
-        if ( FT_NEW_ARRAY( region->axisList, vstore->axisCount ) )
+        if ( FT_QNEW_ARRAY( region->axisList, vstore->axisCount ) )
           goto Exit;
 
         for ( j = 0; j < vstore->axisCount; j++ )
@@ -1213,7 +1212,7 @@
       }
 
       /* use dataOffsetArray now to parse varData items */
-      if ( FT_NEW_ARRAY( vstore->varData, vstore->dataCount ) )
+      if ( FT_QNEW_ARRAY( vstore->varData, vstore->dataCount ) )
         goto Exit;
 
       for ( i = 0; i < vstore->dataCount; i++ )
@@ -1235,7 +1234,7 @@
         if ( FT_READ_USHORT( data->regionIdxCount ) )
           goto Exit;
 
-        if ( FT_NEW_ARRAY( data->regionIndices, data->regionIdxCount ) )
+        if ( FT_QNEW_ARRAY( data->regionIndices, data->regionIdxCount ) )
           goto Exit;
 
         for ( j = 0; j < data->regionIdxCount; j++ )
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 464488d..129ecaa 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -62,7 +62,7 @@
     parser->num_axes    = num_axes;
 
     /* allocate the stack buffer */
-    if ( FT_NEW_ARRAY( parser->stack, stackSize ) )
+    if ( FT_QNEW_ARRAY( parser->stack, stackSize ) )
     {
       FT_FREE( parser->stack );
       goto Exit;