[bdf,pcf] Avoid some memory zeroing.

* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties, pcf_load_font):
Tweak memory macros.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Ditto.
* src/bdf/bdflib.c (_bdf_readstreami, bdf_create_property,
_bdf_parse_glyphs, _bdf_parse_start): Ditto.
(_bdf_add_property): Do not handle zero size.
This commit is contained in:
Alexei Podtelezhnikov 2021-04-25 23:33:15 -04:00
parent f998eaf972
commit c2d283143a
4 changed files with 30 additions and 34 deletions

View File

@ -1,3 +1,14 @@
2021-04-25 Alexei Podtelezhnikov <apodtele@gmail.com>
[bdf,pcf] Avoid some memory zeroing.
* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties, pcf_load_font):
Tweak memory macros.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Ditto.
* src/bdf/bdflib.c (_bdf_readstreami, bdf_create_property,
_bdf_parse_glyphs, _bdf_parse_start): Ditto.
(_bdf_add_property): Do not handle zero size.
2021-04-25 Issam E. Maghni <issam.e.maghni@mailbox.org>
* builds/meson/process_ftoption_h.py: Add LF at EOF.

View File

@ -442,7 +442,7 @@ THE SOFTWARE.
bdfface->num_glyphs = (FT_Long)( font->glyphs_size + 1 );
bdfface->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
if ( FT_NEW( bdfface->available_sizes ) )
goto Exit;
{
@ -451,8 +451,6 @@ THE SOFTWARE.
long value;
FT_ZERO( bsize );
/* sanity checks */
if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
{

View File

@ -538,7 +538,7 @@
/* initial size and allocation of the input buffer */
buf_size = 1024;
if ( FT_NEW_ARRAY( buf, buf_size ) )
if ( FT_QALLOC( buf, buf_size ) )
goto Exit;
cb = callback;
@ -599,7 +599,7 @@
}
new_size = buf_size * 2;
if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) )
if ( FT_QREALLOC( buf, buf_size, new_size ) )
goto Exit;
cursor = (ptrdiff_t)buf_size;
@ -850,13 +850,12 @@
goto Exit;
p = font->user_props + font->nuser_props;
FT_ZERO( p );
n = ft_strlen( name ) + 1;
if ( n > FT_ULONG_MAX )
return FT_THROW( Invalid_Argument );
if ( FT_NEW_ARRAY( p->name, n ) )
if ( FT_QALLOC( p->name, n ) )
goto Exit;
FT_MEM_COPY( (char *)p->name, name, n );
@ -1159,21 +1158,12 @@
/* Allocate another property if this is overflowing. */
if ( font->props_used == font->props_size )
{
if ( font->props_size == 0 )
{
if ( FT_NEW_ARRAY( font->props, 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->props,
font->props_size,
font->props_size + 1 ) )
goto Exit;
}
if ( FT_RENEW_ARRAY( font->props,
font->props_size,
font->props_size + 1 ) )
goto Exit;
fp = font->props + font->props_size;
FT_ZERO( fp );
font->props_size++;
}
@ -1438,7 +1428,7 @@
goto Exit;
}
if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) )
if ( FT_QALLOC( p->glyph_name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->glyph_name, s, slen + 1 );
@ -1735,7 +1725,7 @@
else
glyph->bytes = (unsigned short)bitmap_size;
if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) )
if ( FT_ALLOC( glyph->bitmap, glyph->bytes ) )
goto Exit;
p->row = 0;
@ -2055,7 +2045,7 @@
/* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
FT_FREE( p->font->name );
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
if ( FT_QALLOC( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );

View File

@ -127,7 +127,7 @@ THE SOFTWARE.
toc->count = FT_MIN( stream->size >> 4, 9 );
}
if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
if ( FT_QNEW_ARRAY( face->toc.tables, toc->count ) )
return error;
tables = face->toc.tables;
@ -540,7 +540,7 @@ THE SOFTWARE.
face->nprops = (int)nprops;
if ( FT_NEW_ARRAY( props, nprops ) )
if ( FT_QNEW_ARRAY( props, nprops ) )
goto Bail;
for ( i = 0; i < nprops; i++ )
@ -607,12 +607,11 @@ THE SOFTWARE.
}
/* allocate one more byte so that we have a final null byte */
if ( FT_NEW_ARRAY( strings, string_size + 1 ) )
if ( FT_QALLOC( strings, string_size + 1 ) ||
FT_STREAM_READ( strings, string_size ) )
goto Bail;
error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );
if ( error )
goto Bail;
strings[string_size] = '\0';
if ( FT_NEW_ARRAY( properties, nprops ) )
goto Bail;
@ -1532,7 +1531,7 @@ THE SOFTWARE.
{
l += ft_strlen( foundry_prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
if ( FT_QALLOC( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, foundry_prop->value.atom );
@ -1541,7 +1540,7 @@ THE SOFTWARE.
}
else
{
if ( FT_NEW_ARRAY( root->family_name, l ) )
if ( FT_QALLOC( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
@ -1565,7 +1564,7 @@ THE SOFTWARE.
root->num_glyphs = (FT_Long)face->nmetrics;
root->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
if ( FT_NEW( root->available_sizes ) )
goto Exit;
{
@ -1573,8 +1572,6 @@ THE SOFTWARE.
FT_Short resolution_x = 0, resolution_y = 0;
FT_ZERO( bsize );
/* for simplicity, we take absolute values of integer properties */
#if 0