[truetype] Simplify twilight zone management.

* include/freetype/internal/tttypes.h (TT_GlyphZone): Remove 'memory'.
* src/truetype/ttobjs.c (tt_glyphzone_done): Use 'memory' as argument.
(tt_glyphzone_new, tt_glyphzone_done): Allocate/free as a single block.
(tt_size_init_bytecode, tt_size_done_bytecode): Updated.
* src/truetype/ttobjs.h (tt_glyphzone_done): Updated signature.
This commit is contained in:
Alexei Podtelezhnikov 2025-06-20 20:20:54 -04:00
parent 3ccc27dc52
commit 2041c65cd2
3 changed files with 20 additions and 34 deletions

View file

@ -1613,9 +1613,6 @@ FT_BEGIN_HEADER
* coordinates.
*
* @fields:
* memory ::
* A handle to the memory manager.
*
* n_points ::
* The current number of points in the zone.
*
@ -1639,7 +1636,6 @@ FT_BEGIN_HEADER
*/
typedef struct TT_GlyphZoneRec_
{
FT_Memory memory;
FT_UShort n_points; /* number of points in zone */
FT_UShort n_contours; /* number of contours */

View file

@ -67,23 +67,13 @@
* A pointer to the target glyph zone.
*/
FT_LOCAL_DEF( void )
tt_glyphzone_done( TT_GlyphZone zone )
tt_glyphzone_done( FT_Memory memory,
TT_GlyphZone zone )
{
FT_Memory memory = zone->memory;
FT_FREE( zone->org );
if ( memory )
{
FT_FREE( zone->contours );
FT_FREE( zone->tags );
FT_FREE( zone->cur );
FT_FREE( zone->org );
FT_FREE( zone->orus );
zone->n_points = 0;
zone->n_contours = 0;
zone->memory = NULL;
}
zone->n_points = 0;
zone->n_contours = 0;
}
@ -119,23 +109,22 @@
TT_GlyphZone zone )
{
FT_Error error;
FT_Long size = 3 * maxPoints * sizeof ( FT_Vector ) +
maxContours * sizeof ( FT_UShort ) +
maxPoints * sizeof ( FT_Byte );
FT_ZERO( zone );
zone->memory = memory;
if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
FT_NEW_ARRAY( zone->cur, maxPoints ) ||
FT_NEW_ARRAY( zone->orus, maxPoints ) ||
FT_NEW_ARRAY( zone->tags, maxPoints ) ||
FT_NEW_ARRAY( zone->contours, maxContours ) )
{
tt_glyphzone_done( zone );
}
else
if ( !FT_ALLOC( zone->org, size ) )
{
zone->n_points = maxPoints;
zone->n_contours = maxContours;
zone->cur = zone->org + maxPoints;
zone->orus = zone->cur + maxPoints;
zone->contours = (FT_UShort*)( zone->orus + maxPoints );
zone->tags = (FT_Byte*)( zone->contours + maxContours );
zone->first_point = 0;
}
return error;
@ -1051,7 +1040,7 @@
size->storage_size = 0;
/* twilight zone */
tt_glyphzone_done( &size->twilight );
tt_glyphzone_done( memory, &size->twilight );
FT_FREE( size->function_defs );
FT_FREE( size->instruction_defs );
@ -1092,7 +1081,7 @@
if ( size->context )
TT_Done_Context( size->context );
tt_glyphzone_done( &size->twilight );
tt_glyphzone_done( memory, &size->twilight );
size->bytecode_ready = -1;
size->cvt_ready = -1;

View file

@ -101,7 +101,8 @@ FT_BEGIN_HEADER
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( void )
tt_glyphzone_done( TT_GlyphZone zone );
tt_glyphzone_done( FT_Memory memory,
TT_GlyphZone zone );
FT_LOCAL( FT_Error )
tt_glyphzone_new( FT_Memory memory,