summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2022-01-26 11:23:38 -0500
committerAlexei Podtelezhnikov <apodtele@gmail.com>2022-01-26 11:23:38 -0500
commit09223ef92925ec3ce76670fd09c0d4e03fb18b26 (patch)
treef4e30b96c077b37ac8615ad0d48ece3cdc835e06
parent267c6918d1575c83fc4412e3ffff91ae0b07b823 (diff)
downloadfreetype2-09223ef92925ec3ce76670fd09c0d4e03fb18b26.tar.gz
[pcf] Delay encoding allocation and avoid its zeroing.
* src/pcf/pcfread.c (pcf_get_encodings): Refactor and use FT_QNEW_ARRAY.
-rw-r--r--src/pcf/pcfread.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index e60a0a514..f167bcb8a 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1034,16 +1034,6 @@ THE SOFTWARE.
enc->lastRow > 0xFF )
return FT_THROW( Invalid_Table );
- nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) *
- (FT_ULong)( enc->lastRow - enc->firstRow + 1 );
-
- if ( FT_NEW_ARRAY( enc->offset, nencoding ) )
- goto Bail;
-
- error = FT_Stream_EnterFrame( stream, 2 * nencoding );
- if ( error )
- goto Exit;
-
FT_TRACE5(( "\n" ));
defaultCharRow = enc->defaultChar >> 8;
@@ -1064,6 +1054,13 @@ THE SOFTWARE.
defaultCharCol = enc->firstCol;
}
+ nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) *
+ (FT_ULong)( enc->lastRow - enc->firstRow + 1 );
+
+ error = FT_Stream_EnterFrame( stream, 2 * nencoding );
+ if ( error )
+ goto Bail;
+
/*
* FreeType mandates that glyph index 0 is the `undefined glyph', which
* PCF calls the `default character'. However, FreeType needs glyph
@@ -1109,6 +1106,9 @@ THE SOFTWARE.
/* copy metrics of default character to index 0 */
face->metrics[0] = face->metrics[defaultCharEncodingOffset];
+ if ( FT_QNEW_ARRAY( enc->offset, nencoding ) )
+ goto Bail;
+
/* now loop over all values */
offset = enc->offset;
for ( i = enc->firstRow; i <= enc->lastRow; i++ )
@@ -1131,11 +1131,6 @@ THE SOFTWARE.
}
FT_Stream_ExitFrame( stream );
- return error;
-
- Exit:
- FT_FREE( enc->offset );
-
Bail:
return error;
}