diff --git a/ChangeLog b/ChangeLog index eeef68d09..cd477b3eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,28 @@ 2002-03-22 David Turner + * include/freetype/internal/ftmemory.h, and a lot of other files !!: + + changed the names of memory macros. Examples: + + MEM_Set => FT_MEM_SET + MEM_Copy => FT_MEM_COPY + MEM_Move => FT_MEM_MOVE + + ALLOC => FT_ALLOC + FREE => FT_FREE + REALLOC = >FT_REALLOC + + FT_NEW was introduced to allocate a new object from a _typed_ + pointer.. + + note that ALLOC_ARRAY and REALLOC_ARRAY have been replaced + by FT_NEW_ARRAY and FT_RENEW_ARRAY which take _typed_ pointer + arguments. + + This results in _lots_ of sources being changed, but makes the + code more generic and less error-prone.. + + * include/freetype/internal/ftstream.h, src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c, src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c, diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h index f2da6feca..b68871a88 100644 --- a/include/freetype/internal/ftmemory.h +++ b/include/freetype/internal/ftmemory.h @@ -176,107 +176,116 @@ FT_BEGIN_HEADER /* available on all platforms we know of. */ #include -#define MEM_Set( dest, byte, count ) memset( dest, byte, count ) +#define FT_MEM_SET( dest, byte, count ) memset( dest, byte, count ) -#define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) +#define FT_MEM_COPY( dest, source, count ) memcpy( dest, source, count ) -#define MEM_Move( dest, source, count ) memmove( dest, source, count ) +#define FT_MEM_MOVE( dest, source, count ) memmove( dest, source, count ) - /*************************************************************************/ - /* */ - /* We now support closures to produce completely reentrant code. This */ - /* means the allocation functions now takes an additional argument */ - /* (`memory'). It is a handle to a given memory object, responsible for */ - /* all low-level operations, including memory management and */ - /* synchronisation. */ - /* */ - /* In order to keep our code readable and use the same macros in the */ - /* font drivers and the rest of the library, MEM_Alloc(), ALLOC(), and */ - /* ALLOC_ARRAY() now use an implicit variable, `memory'. It must be */ - /* defined at all locations where a memory operation is queried. */ - /* */ +/************************************************************************** + * + * we first define FT_MEM_ALLOC, FT_MEM_REALLOC and FT_MEM_FREE + * all macros use an _implicit_ 'memory' parameter to access the + * current memory allocator + * + */ #ifdef FT_DEBUG_MEMORY -#define MEM_Alloc( _pointer_, _size_ ) \ - FT_Alloc_Debug( memory, _size_, \ +# define FT_MEM_ALLOC( _pointer_, _size_ ) \ + FT_Alloc_Debug( memory, _size_, \ (void**)&(_pointer_), __FILE__, __LINE__ ) -#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \ - FT_Alloc_Debug( memory, (_count_)*sizeof ( _type_ ), \ - (void**)&(_pointer_), __FILE__, __LINE__ ) - -#define MEM_Realloc( _pointer_, _current_, _size_ ) \ - FT_Realloc_Debug( memory, _current_, _size_, \ +# define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ + FT_Realloc_Debug( memory, _current_, _size_, \ (void**)&(_pointer_), __FILE__, __LINE__ ) -#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \ - FT_Realloc_Debug( memory, (_current_)*sizeof ( _type_ ), \ - (_new_)*sizeof ( _type_ ), \ - (void**)&(_pointer_), __FILE__, __LINE__ ) - -#define MEM_Free( _pointer_ ) \ +# define FT_MEM_FREE( _pointer_ ) \ FT_Free_Debug( memory, (void**)&(_pointer_), __FILE__, __LINE__ ) + #else /* !FT_DEBUG_MEMORY */ -#define MEM_Alloc( _pointer_, _size_ ) \ +# define FT_MEM_ALLOC( _pointer_, _size_ ) \ FT_Alloc( memory, _size_, (void**)&(_pointer_) ) -#define MEM_New( _pointer_ ) MEM_Alloc( _pointer_, sizeof(*(_pointer_)) ) - - -#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \ - FT_Alloc( memory, (_count_)*sizeof ( _type_ ), \ - (void**)&(_pointer_) ) - -#define MEM_New_Array( _pointer_, _count_ ) \ - MEM_Alloc_Array( _pointer_, _count_, sizeof(*(_pointer_)) ) - -#define MEM_Realloc( _pointer_, _current_, _size_ ) \ - FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) ) - -#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \ - FT_Realloc( memory, (_current_)*sizeof ( _type_ ), \ - (_new_)*sizeof ( _type_ ), (void**)&(_pointer_) ) - -#define MEM_Renew_Array( _pointer_, _current_, _new_ ) \ - MEM_Realloc_Array( _pointer_, _current_, _new_, *(_pointer_) ) - -#define MEM_Free( _pointer_ ) \ +# define FT_MEM_FREE( _pointer_ ) \ FT_Free( memory, (void**)&(_pointer_) ) +# define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ + FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) ) + #endif /* !FT_DEBUG_MEMORY */ -#define ALLOC( _pointer_, _size_ ) \ - FT_SET_ERROR( MEM_Alloc( _pointer_, _size_ ) ) +/************************************************************************** + * + * the following functions macros that their pointer argument is _typed_ + * in order to automatically compute array element sizes.. + */ +#define FT_MEM_NEW( _pointer_ ) \ + FT_MEM_ALLOC( _pointer_, sizeof(*(_pointer_)) ) -#define NEW( _pointer_ ) \ - FT_SET_ERROR( MEM_New( _pointer_ ) ) +#define FT_MEM_NEW_ARRAY( _pointer_, _count_ ) \ + FT_MEM_ALLOC( _pointer_, (_count_)*sizeof(*(_pointer_)) ) -#define REALLOC( _pointer_, _current_, _size_ ) \ - FT_SET_ERROR( MEM_Realloc( _pointer_, _current_, _size_ ) ) +#define FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ + FT_MEM_REALLOC( _pointer_, (_old_)*sizeof(*(_pointer_)), \ + (_new_)*sizeof(*(_pointer_)) ) -#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - FT_SET_ERROR( MEM_Alloc( _pointer_, \ + +/************************************************************************** + * + * the following macros are obsolete but kept for compatibility reasons + */ + +#define FT_MEM_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + FT_MEM_ALLOC( _pointer_, (_count_)*sizeof(_type_) ) + +#define FT_MEM_REALLOC_ARRAY( _pointer_, _current_, _new_, _type_ ) \ + FT_MEM_REALLOC( _pointer_, (_current_)*sizeof(_type), \ + (_new_)*sizeof(_type_) ) + + + +/************************************************************************** + * + * the following macros are variants of their FT_MEM_XXXX equivalents + * they're used to set an _implicit_ 'error' variable and return TRUE + * if an error occured (i.e. if 'error != 0') + */ + + + +#define FT_ALLOC( _pointer_, _size_ ) \ + FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) ) + +#define FT_REALLOC( _pointer_, _current_, _size_ ) \ + FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) ) + +#define FT_FREE( _pointer_ ) \ + FT_MEM_FREE( _pointer_ ) + +#define FT_NEW( _pointer_ ) \ + FT_SET_ERROR( FT_MEM_NEW( _pointer_ ) ) + +#define FT_RENEW_ARRAY( _pointer_, _current_, _new_ ) \ + FT_SET_ERROR( FT_MEM_RENEW_ARRAY( _pointer_, _current_, _new_ ) ) + + +#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, \ (_count_)*sizeof ( _type_ ) ) ) -#define NEW_ARRAY( _pointer_, _count_ ) \ - FT_SET_ERROR( MEM_New_Array( _pointer_, _count_ ) ) +#define FT_NEW_ARRAY( _pointer_, _count_ ) \ + FT_SET_ERROR( FT_MEM_NEW_ARRAY( _pointer_, _count_ ) ) -#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \ - FT_SET_ERROR( MEM_Realloc( _pointer_, \ +#define FT_REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \ + FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, \ (_current_)*sizeof ( _type_ ), \ (_count_)*sizeof ( _type_ ) ) ) - -#define RENEW_ARRAY( _pointer_, _current_, _new_ ) \ - FT_SET_ERROR( MEM_Renew_Array( _pointer_, _current_, _new_ ) ) - -#define FREE( _pointer_ ) \ - MEM_Free( _pointer_ ) - + /* */ FT_END_HEADER diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c index 65a42a8ac..75fcbcfd4 100644 --- a/src/autohint/ahglyph.c +++ b/src/autohint/ahglyph.c @@ -307,7 +307,7 @@ AH_Outline* outline; - if ( !ALLOC( outline, sizeof ( *outline ) ) ) + if ( !FT_NEW( outline ) ) { outline->memory = memory; *aoutline = outline; @@ -331,12 +331,12 @@ FT_Memory memory = outline->memory; - FREE( outline->horz_edges ); - FREE( outline->horz_segments ); - FREE( outline->contours ); - FREE( outline->points ); + FT_FREE( outline->horz_edges ); + FT_FREE( outline->horz_segments ); + FT_FREE( outline->contours ); + FT_FREE( outline->points ); - FREE( outline ); + FT_FREE( outline ); } @@ -408,8 +408,9 @@ FT_Int new_contours = ( num_contours + 3 ) & -4; - if ( REALLOC_ARRAY( outline->contours, outline->max_contours, - new_contours, AH_Point* ) ) + if ( FT_RENEW_ARRAY( outline->contours, + outline->max_contours, + new_contours ) ) goto Exit; outline->max_contours = new_contours; @@ -425,12 +426,9 @@ FT_Int max = outline->max_points; - if ( REALLOC_ARRAY( outline->points, - max, news, AH_Point ) || - REALLOC_ARRAY( outline->horz_edges, - max * 2, news * 2, AH_Edge ) || - REALLOC_ARRAY( outline->horz_segments, - max * 2, news * 2, AH_Segment ) ) + if ( FT_RENEW_ARRAY( outline->points, max, news ) || + FT_RENEW_ARRAY( outline->horz_edges, max * 2, news * 2 ) || + FT_RENEW_ARRAY( outline->horz_segments, max * 2, news * 2 ) ) goto Exit; /* readjust some pointers */ @@ -816,7 +814,7 @@ segment_dir = point->out_dir; /* clear all segment fields */ - MEM_Set( segment, 0, sizeof ( *segment ) ); + FT_MEM_SET( segment, 0, sizeof ( *segment ) ); segment->dir = segment_dir; segment->flags = ah_edge_normal; @@ -878,7 +876,7 @@ if ( min_point ) { /* clear all segment fields */ - MEM_Set( segment, 0, sizeof ( *segment ) ); + FT_MEM_SET( segment, 0, sizeof ( *segment ) ); segment->dir = segment_dir; segment->flags = ah_edge_normal; @@ -894,7 +892,7 @@ if ( max_point ) { /* clear all segment fields */ - MEM_Set( segment, 0, sizeof ( *segment ) ); + FT_MEM_SET( segment, 0, sizeof ( *segment ) ); segment->dir = segment_dir; segment->flags = ah_edge_normal; @@ -1117,7 +1115,7 @@ edge_limit++; /* clear all edge fields */ - MEM_Set( edge, 0, sizeof ( *edge ) ); + FT_MEM_SET( edge, 0, sizeof ( *edge ) ); /* add the segment to the new edge's list */ edge->first = seg; diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c index 423c92ee2..d2a8e908a 100644 --- a/src/autohint/ahhint.c +++ b/src/autohint/ahhint.c @@ -913,7 +913,7 @@ hinter->globals = 0; hinter->face = 0; - FREE( hinter ); + FT_FREE( hinter ); } } @@ -931,7 +931,7 @@ *ahinter = 0; /* allocate object */ - if ( ALLOC( hinter, sizeof ( *hinter ) ) ) + if ( FT_NEW( hinter ) ) goto Exit; hinter->memory = memory; @@ -965,7 +965,7 @@ AH_Face_Globals* face_globals; - if ( ALLOC( face_globals, sizeof ( *face_globals ) ) ) + if ( FT_NEW( face_globals ) ) goto Exit; hinter->face = face; @@ -994,7 +994,7 @@ FT_Memory memory = face->memory; - FREE( globals ); + FT_FREE( globals ); } @@ -1067,13 +1067,13 @@ if ( error ) goto Exit; - MEM_Copy( gloader->current.extra_points, slot->outline.points, + FT_MEM_COPY( gloader->current.extra_points, slot->outline.points, slot->outline.n_points * sizeof ( FT_Vector ) ); - MEM_Copy( gloader->current.outline.contours, slot->outline.contours, + FT_MEM_COPY( gloader->current.outline.contours, slot->outline.contours, slot->outline.n_contours * sizeof ( short ) ); - MEM_Copy( gloader->current.outline.tags, slot->outline.tags, + FT_MEM_COPY( gloader->current.outline.tags, slot->outline.tags, slot->outline.n_points * sizeof ( char ) ); gloader->current.outline.n_points = slot->outline.n_points; @@ -1151,7 +1151,7 @@ if ( error ) goto Exit; - MEM_Copy( gloader->current.subglyphs, slot->subglyphs, + FT_MEM_COPY( gloader->current.subglyphs, slot->subglyphs, num_subglyphs * sizeof ( FT_SubGlyph ) ); gloader->current.num_subglyphs = num_subglyphs; @@ -1393,7 +1393,7 @@ /* allocate new master globals */ - if ( ALLOC( globals, sizeof ( *globals ) ) ) + if ( FT_NEW( globals ) ) goto Fail; /* compute face globals if needed */ @@ -1411,7 +1411,7 @@ return; Fail: - FREE( globals ); + FT_FREE( globals ); *global_hints = 0; *global_len = 0; @@ -1425,7 +1425,7 @@ FT_Memory memory = hinter->memory; - FREE( global_hints ); + FT_FREE( global_hints ); } diff --git a/src/autohint/ahoptim.c b/src/autohint/ahoptim.c index 87c9ee5e7..3a6e0752b 100644 --- a/src/autohint/ahoptim.c +++ b/src/autohint/ahoptim.c @@ -32,7 +32,7 @@ #include -#include FT_INTERNAL_OBJECTS_H /* for ALLOC_ARRAY() and FREE() */ +#include FT_INTERNAL_OBJECTS_H /* for FT_ALLOC_ARRAY() and FT_FREE() */ #include "ahoptim.h" @@ -220,7 +220,7 @@ AH_Stem* stem; - if ( ALLOC_ARRAY( stems, num_stems, AH_Stem ) ) + if ( FT_NEW_ARRAY( stems, num_stems ) ) goto Exit; stem = stems; @@ -409,7 +409,7 @@ /* allocate table of springs */ - if ( ALLOC_ARRAY( springs, num_springs, AH_Spring ) ) + if ( FT_NEW_ARRAY( springs, num_springs ) ) goto Exit; /* fill the springs table */ @@ -796,11 +796,11 @@ FT_Memory memory = optimizer->memory; - FREE( optimizer->horz_stems ); - FREE( optimizer->vert_stems ); - FREE( optimizer->horz_springs ); - FREE( optimizer->vert_springs ); - FREE( optimizer->positions ); + FT_FREE( optimizer->horz_stems ); + FT_FREE( optimizer->vert_stems ); + FT_FREE( optimizer->horz_springs ); + FT_FREE( optimizer->vert_springs ); + FT_FREE( optimizer->positions ); } } @@ -814,7 +814,7 @@ FT_Error error; - MEM_Set( optimizer, 0, sizeof ( *optimizer ) ); + FT_MEM_SET( optimizer, 0, sizeof ( *optimizer ) ); optimizer->outline = outline; optimizer->memory = memory; @@ -834,8 +834,7 @@ if ( max_stems < optimizer->num_vstems ) max_stems = optimizer->num_vstems; - if ( ALLOC_ARRAY( optimizer->positions, - max_stems * AH_MAX_CONFIGS, FT_Pos ) ) + if ( FT_NEW_ARRAY( optimizer->positions, max_stems * AH_MAX_CONFIGS ) ) goto Fail; optimizer->num_configs = 0; diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c index b2896489a..6aaa3680b 100644 --- a/src/base/ftdbgmem.c +++ b/src/base/ftdbgmem.c @@ -205,7 +205,7 @@ if ( new_buckets == NULL ) return; - MEM_Set( new_buckets, 0, sizeof ( FT_MemNode ) * new_size ); + FT_MEM_SET( new_buckets, 0, sizeof ( FT_MemNode ) * new_size ); for ( i = 0; i < table->size; i++ ) { @@ -246,7 +246,7 @@ if ( table == NULL ) goto Exit; - MEM_Set( table, 0, sizeof ( *table ) ); + FT_MEM_SET( table, 0, sizeof ( *table ) ); table->size = FT_MEM_SIZE_MIN; table->nodes = 0; @@ -263,7 +263,7 @@ memory->alloc( memory, table->size * sizeof ( FT_MemNode ) ); if ( table->buckets ) - MEM_Set( table->buckets, 0, sizeof ( FT_MemNode ) * table->size ); + FT_MEM_SET( table->buckets, 0, sizeof ( FT_MemNode ) * table->size ); else { memory->free( memory, table ); @@ -452,7 +452,7 @@ /* we simply invert the node's size to indicate that the node */ /* was freed. We also change its contents. */ - MEM_Set( address, 0xF3, node->size ); + FT_MEM_SET( address, 0xF3, node->size ); table->alloc_current -= node->size; node->size = -node->size; diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c index a181e5f6e..71acda6e3 100644 --- a/src/base/ftgloadr.c +++ b/src/base/ftgloadr.c @@ -53,7 +53,7 @@ FT_Error error; - if ( !ALLOC( loader, sizeof ( *loader ) ) ) + if ( !FT_NEW( loader ) ) { loader->memory = memory; *aloader = loader; @@ -86,11 +86,11 @@ FT_Memory memory = loader->memory; - FREE( loader->base.outline.points ); - FREE( loader->base.outline.tags ); - FREE( loader->base.outline.contours ); - FREE( loader->base.extra_points ); - FREE( loader->base.subglyphs ); + FT_FREE( loader->base.outline.points ); + FT_FREE( loader->base.outline.tags ); + FT_FREE( loader->base.outline.contours ); + FT_FREE( loader->base.extra_points ); + FT_FREE( loader->base.subglyphs ); loader->max_points = 0; loader->max_contours = 0; @@ -110,7 +110,7 @@ FT_GlyphLoader_Reset( loader ); - FREE( loader ); + FT_FREE( loader ); } } @@ -141,8 +141,7 @@ FT_Memory memory = loader->memory; - if ( !ALLOC_ARRAY( loader->base.extra_points, - loader->max_points, FT_Vector ) ) + if ( !FT_NEW_ARRAY( loader->base.extra_points, loader->max_points ) ) { loader->use_extra = 1; FT_GlyphLoader_Adjust_Points( loader ); @@ -189,13 +188,12 @@ { new_max = ( new_max + 7 ) & -8; - if ( REALLOC_ARRAY( base->points, old_max, new_max, FT_Vector ) || - REALLOC_ARRAY( base->tags, old_max, new_max, FT_Byte ) ) + if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) || + FT_RENEW_ARRAY( base->tags, old_max, new_max ) ) goto Exit; if ( loader->use_extra && - REALLOC_ARRAY( loader->base.extra_points, old_max, - new_max, FT_Vector ) ) + FT_RENEW_ARRAY( loader->base.extra_points, old_max, new_max ) ) goto Exit; adjust = 1; @@ -209,7 +207,7 @@ if ( new_max > old_max ) { new_max = ( new_max + 3 ) & -4; - if ( REALLOC_ARRAY( base->contours, old_max, new_max, FT_Short ) ) + if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) ) goto Exit; adjust = 1; @@ -245,7 +243,7 @@ if ( new_max > old_max ) { new_max = ( new_max + 1 ) & -2; - if ( REALLOC_ARRAY( base->subglyphs, old_max, new_max, FT_SubGlyphRec ) ) + if ( FT_RENEW_ARRAY( base->subglyphs, old_max, new_max ) ) goto Exit; loader->max_subglyphs = new_max; @@ -319,16 +317,16 @@ FT_Outline* in = &source->base.outline; - MEM_Copy( out->points, in->points, + FT_MEM_COPY( out->points, in->points, num_points * sizeof ( FT_Vector ) ); - MEM_Copy( out->tags, in->tags, + FT_MEM_COPY( out->tags, in->tags, num_points * sizeof ( char ) ); - MEM_Copy( out->contours, in->contours, + FT_MEM_COPY( out->contours, in->contours, num_contours * sizeof ( short ) ); /* do we need to copy the extra points? */ if ( target->use_extra && source->use_extra ) - MEM_Copy( target->base.extra_points, source->base.extra_points, + FT_MEM_COPY( target->base.extra_points, source->base.extra_points, num_points * sizeof ( FT_Vector ) ); out->n_points = (short)num_points; diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 2db16ee22..f2e6f7a2c 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -131,8 +131,8 @@ size = (FT_ULong)( pitch * source->rows ); - if ( !ALLOC( target->buffer, size ) ) - MEM_Copy( target->buffer, source->buffer, size ); + if ( !FT_ALLOC( target->buffer, size ) ) + FT_MEM_COPY( target->buffer, source->buffer, size ); return error; } @@ -191,7 +191,7 @@ FT_Memory memory = FT_GLYPH(glyph)->library->memory; - FREE( glyph->bitmap.buffer ); + FT_FREE( glyph->bitmap.buffer ); } @@ -253,13 +253,13 @@ goto Exit; /* copy it */ - MEM_Copy( target->points, source->points, + FT_MEM_COPY( target->points, source->points, source->n_points * sizeof ( FT_Vector ) ); - MEM_Copy( target->tags, source->tags, + FT_MEM_COPY( target->tags, source->tags, source->n_points * sizeof ( FT_Byte ) ); - MEM_Copy( target->contours, source->contours, + FT_MEM_COPY( target->contours, source->contours, source->n_contours * sizeof ( FT_Short ) ); /* copy all flags, except the `ft_outline_owner' one */ @@ -361,7 +361,7 @@ *aglyph = 0; - if ( !ALLOC( glyph, clazz->glyph_size ) ) + if ( !FT_ALLOC( glyph, clazz->glyph_size ) ) { glyph->library = library; glyph->clazz = clazz; @@ -594,7 +594,7 @@ if ( !clazz || !clazz->glyph_prepare ) goto Bad; - MEM_Set( &dummy, 0, sizeof ( dummy ) ); + FT_MEM_SET( &dummy, 0, sizeof ( dummy ) ); dummy.library = glyph->library; dummy.format = clazz->glyph_format; @@ -671,7 +671,7 @@ if ( clazz->glyph_done ) clazz->glyph_done( glyph ); - FREE( glyph ); + FT_FREE( glyph ); } } diff --git a/src/base/ftlist.c b/src/base/ftlist.c index b51691823..6dbfb09f9 100644 --- a/src/base/ftlist.c +++ b/src/base/ftlist.c @@ -205,7 +205,7 @@ if ( destroy ) destroy( memory, data, user ); - FREE( cur ); + FT_FREE( cur ); cur = next; } diff --git a/src/base/ftmac.c b/src/base/ftmac.c index 5e3ee780b..e9ddc26a8 100644 --- a/src/base/ftmac.c +++ b/src/base/ftmac.c @@ -364,7 +364,7 @@ last_code = code; } - if ( ALLOC( buffer, (FT_Long)total_size ) ) + if ( FT_ALLOC( buffer, (FT_Long)total_size ) ) goto Error; /* Second pass: append all POST data to the buffer, add PFB fields. @@ -433,7 +433,7 @@ FT_Memory memory = stream->memory; - FREE( stream->base ); + FT_FREE( stream->base ); stream->size = 0; stream->base = 0; @@ -462,7 +462,7 @@ *astream = 0; memory = library->memory; - if ( ALLOC( stream, sizeof ( *stream ) ) ) + if ( FT_NEW( stream ) ) goto Exit; FT_Stream_OpenMemory( library, @@ -501,7 +501,7 @@ &stream ); if ( error ) { - FREE( base ); + FT_FREE( base ); return error; } @@ -519,7 +519,7 @@ else { FT_Stream_Close( stream ); - FREE( stream ); + FT_FREE( stream ); } return error; } @@ -588,7 +588,7 @@ return FT_Err_Invalid_Handle; sfnt_size = (FT_ULong)GetHandleSize( sfnt ); - if ( ALLOC( sfnt_data, (FT_Long)sfnt_size ) ) + if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) ) { ReleaseResource( sfnt ); return error; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 040e9efb8..7ab8c4a88 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -61,7 +61,7 @@ *astream = 0; memory = library->memory; - if ( ALLOC( stream, sizeof ( *stream ) ) ) + if ( FT_NEW( stream ) ) goto Exit; stream->memory = memory; @@ -85,14 +85,14 @@ /* in this case, we do not need to allocate a new stream object */ /* since the caller is responsible for closing it himself */ - FREE( stream ); + FT_FREE( stream ); stream = args->stream; } else error = FT_Err_Invalid_Argument; if ( error ) - FREE( stream ); + FT_FREE( stream ); else stream->memory = memory; /* just to be certain */ @@ -115,7 +115,7 @@ FT_Stream_Close( stream ); if ( !external ) - FREE( stream ); + FT_FREE( stream ); } } @@ -149,7 +149,7 @@ slot->library = driver->root.library; - if ( ALLOC( internal, sizeof ( *internal ) ) ) + if ( FT_NEW( internal ) ) goto Exit; slot->internal = internal; @@ -174,14 +174,14 @@ FT_Memory memory = FT_FACE_MEMORY( slot->face ); - FREE( slot->bitmap.buffer ); + FT_FREE( slot->bitmap.buffer ); slot->flags &= ~FT_GLYPH_OWN_BITMAP; } /* clear all public fields in the glyph slot */ - MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) ); - MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) ); - MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) ); + FT_MEM_SET( &slot->metrics, 0, sizeof ( slot->metrics ) ); + FT_MEM_SET( &slot->outline, 0, sizeof ( slot->outline ) ); + FT_MEM_SET( &slot->bitmap, 0, sizeof ( slot->bitmap ) ); slot->bitmap_left = 0; slot->bitmap_top = 0; @@ -210,7 +210,7 @@ /* free bitmap buffer if needed */ if ( slot->flags & FT_GLYPH_OWN_BITMAP ) - FREE( slot->bitmap.buffer ); + FT_FREE( slot->bitmap.buffer ); /* free glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) @@ -219,7 +219,7 @@ slot->internal->loader = 0; } - FREE( slot->internal ); + FT_FREE( slot->internal ); } @@ -246,7 +246,7 @@ memory = driver->root.memory; FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); - if ( !ALLOC( slot, clazz->slot_object_size ) ) + if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) { slot->face = face; @@ -254,7 +254,7 @@ if ( error ) { ft_glyphslot_done( slot ); - FREE( slot ); + FT_FREE( slot ); goto Exit; } @@ -290,7 +290,7 @@ { *parent = cur->next; ft_glyphslot_done( slot ); - FREE( slot ); + FT_FREE( slot ); break; } cur = cur->next; @@ -547,8 +547,8 @@ if ( driver->clazz->done_size ) driver->clazz->done_size( size ); - FREE( size->internal ); - FREE( size ); + FT_FREE( size->internal ); + FT_FREE( size ); } @@ -594,10 +594,10 @@ /* get rid of it */ if ( face->internal ) { - FREE( face->internal->postscript_name ); - FREE( face->internal ); + FT_FREE( face->internal->postscript_name ); + FT_FREE( face->internal ); } - FREE( face ); + FT_FREE( face ); } @@ -642,10 +642,10 @@ memory = driver->root.memory; /* allocate the face object and perform basic initialization */ - if ( ALLOC( face, clazz->face_object_size ) ) + if ( FT_ALLOC( face, clazz->face_object_size ) ) goto Fail; - if ( ALLOC( internal, sizeof ( *internal ) ) ) + if ( FT_NEW( internal ) ) goto Fail; face->internal = internal; @@ -668,8 +668,8 @@ if ( error ) { clazz->done_face( face ); - FREE( face->internal ); - FREE( face ); + FT_FREE( face->internal ); + FT_FREE( face ); *aface = 0; } @@ -845,7 +845,7 @@ face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; /* add the face object to its driver's list */ - if ( ALLOC( node, sizeof ( *node ) ) ) + if ( FT_NEW( node ) ) goto Fail; node->data = face; @@ -996,7 +996,7 @@ { /* remove face object from the driver's list */ FT_List_Remove( &driver->faces_list, node ); - FREE( node ); + FT_FREE( node ); /* now destroy the object proper */ destroy_face( memory, face, driver ); @@ -1038,8 +1038,7 @@ memory = face->memory; /* Allocate new size object and perform basic initialisation */ - if ( ALLOC( size, clazz->size_object_size ) || - ALLOC( node, sizeof ( FT_ListNodeRec ) ) ) + if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) ) goto Exit; size->face = face; @@ -1061,8 +1060,8 @@ Exit: if ( error ) { - FREE( node ); - FREE( size ); + FT_FREE( node ); + FT_FREE( size ); } return error; @@ -1099,7 +1098,7 @@ if ( node ) { FT_List_Remove( &face->sizes_list, node ); - FREE( node ); + FT_FREE( node ); if ( face->size == size ) { @@ -1386,7 +1385,7 @@ if ( clazz->done ) clazz->done( cmap ); - FREE( cmap ); + FT_FREE( cmap ); } } @@ -1408,7 +1407,7 @@ face = charmap->face; memory = FT_FACE_MEMORY(face); - if ( !ALLOC( cmap, clazz->size ) ) + if ( !FT_ALLOC( cmap, clazz->size ) ) { cmap->charmap = *charmap; cmap->clazz = clazz; @@ -1421,10 +1420,9 @@ } /* add it to our list of charmaps */ - if ( REALLOC_ARRAY( face->charmaps, - face->num_charmaps, - face->num_charmaps+1, - FT_CharMap* ) ) + if ( FT_RENEW_ARRAY( face->charmaps, + face->num_charmaps, + face->num_charmaps+1 ) ) goto Fail; face->charmaps[ face->num_charmaps++ ] = (FT_CharMap) cmap; @@ -1771,7 +1769,7 @@ FT_ListNode node; - if ( ALLOC( node, sizeof ( *node ) ) ) + if ( FT_NEW( node ) ) goto Exit; { @@ -1803,7 +1801,7 @@ Fail: if ( error ) - FREE( node ); + FT_FREE( node ); Exit: return error; @@ -1830,7 +1828,7 @@ /* remove from list */ FT_List_Remove( &library->renderers, node ); - FREE( node ); + FT_FREE( node ); ft_set_current_renderer( library ); } @@ -2030,7 +2028,7 @@ clazz->module_done( module ); /* discard it */ - FREE( module ); + FT_FREE( module ); } @@ -2086,7 +2084,7 @@ } /* allocate module object */ - if ( ALLOC( module,clazz->module_size ) ) + if ( FT_ALLOC( module,clazz->module_size ) ) goto Exit; /* base initialization */ @@ -2156,7 +2154,7 @@ renderer->clazz->raster_class->raster_done( renderer->raster ); } - FREE( module ); + FT_FREE( module ); goto Exit; } @@ -2278,14 +2276,14 @@ ft_debug_init(); /* first of all, allocate the library object */ - if ( ALLOC( library, sizeof ( *library ) ) ) + if ( FT_NEW( library ) ) return error; library->memory = memory; /* allocate the render pool */ library->raster_pool_size = FT_RENDER_POOL_SIZE; - if ( ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) + if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) goto Fail; /* That's ok now */ @@ -2294,7 +2292,7 @@ return FT_Err_Ok; Fail: - FREE( library ); + FT_FREE( library ); return error; } @@ -2371,10 +2369,10 @@ #endif /* Destroy raster objects */ - FREE( library->raster_pool ); + FT_FREE( library->raster_pool ); library->raster_pool_size = 0; - FREE( library ); + FT_FREE( library ); return FT_Err_Ok; } diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 142ba0775..d30f695a7 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -263,9 +263,9 @@ *anoutline = null_outline; - if ( ALLOC_ARRAY( anoutline->points, numPoints * 2L, FT_Pos ) || - ALLOC_ARRAY( anoutline->tags, numPoints, FT_Byte ) || - ALLOC_ARRAY( anoutline->contours, numContours, FT_UShort ) ) + if ( FT_NEW_ARRAY( anoutline->points, numPoints * 2L ) || + FT_NEW_ARRAY( anoutline->tags, numPoints ) || + FT_NEW_ARRAY( anoutline->contours, numContours ) ) goto Fail; anoutline->n_points = (FT_UShort)numPoints; @@ -357,13 +357,13 @@ source->n_contours != target->n_contours ) return FT_Err_Invalid_Argument; - MEM_Copy( target->points, source->points, + FT_MEM_COPY( target->points, source->points, source->n_points * sizeof ( FT_Vector ) ); - MEM_Copy( target->tags, source->tags, + FT_MEM_COPY( target->tags, source->tags, source->n_points * sizeof ( FT_Byte ) ); - MEM_Copy( target->contours, source->contours, + FT_MEM_COPY( target->contours, source->contours, source->n_contours * sizeof ( FT_Short ) ); /* copy all flags, except the `ft_outline_owner' one */ @@ -385,9 +385,9 @@ { if ( outline->flags & ft_outline_owner ) { - FREE( outline->points ); - FREE( outline->tags ); - FREE( outline->contours ); + FT_FREE( outline->points ); + FT_FREE( outline->tags ); + FT_FREE( outline->contours ); } *outline = null_outline; diff --git a/src/base/ftstream.c b/src/base/ftstream.c index 7fafbcf83..9266d5099 100644 --- a/src/base/ftstream.c +++ b/src/base/ftstream.c @@ -138,7 +138,7 @@ if ( read_bytes > count ) read_bytes = count; - MEM_Copy( buffer, stream->base + pos, read_bytes ); + FT_MEM_COPY( buffer, stream->base + pos, read_bytes ); } stream->pos = pos + read_bytes; @@ -186,7 +186,7 @@ FT_Memory memory = stream->memory; - FREE( *pbytes ); + FT_FREE( *pbytes ); } *pbytes = 0; } @@ -209,7 +209,7 @@ FT_Memory memory = stream->memory; - if ( ALLOC( stream->base, count ) ) + if ( FT_ALLOC( stream->base, count ) ) goto Exit; /* read it */ @@ -221,7 +221,7 @@ FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n", count, read_bytes )); - FREE( stream->base ); + FT_FREE( stream->base ); error = FT_Err_Invalid_Stream_Operation; } stream->cursor = stream->base; @@ -272,7 +272,7 @@ FT_Memory memory = stream->memory; - FREE( stream->base ); + FT_FREE( stream->base ); } stream->cursor = 0; stream->limit = 0; @@ -704,7 +704,7 @@ if ( fields->value == ft_frame_bytes ) { p = (FT_Byte*)structure + fields->offset; - MEM_Copy( p, cursor, len ); + FT_MEM_COPY( p, cursor, len ); } cursor += len; fields++; diff --git a/src/base/ftutil.c b/src/base/ftutil.c index f8cf7d3e7..5c3507e4c 100644 --- a/src/base/ftutil.c +++ b/src/base/ftutil.c @@ -46,7 +46,7 @@ return FT_Err_Out_Of_Memory; } - MEM_Set( *P, 0, size ); + FT_MEM_SET( *P, 0, size ); } else *P = NULL; @@ -88,7 +88,7 @@ goto Fail; if ( size > current ) - MEM_Set( (char*)Q + current, 0, size - current ); + FT_MEM_SET( (char*)Q + current, 0, size - current ); *P = Q; return FT_Err_Ok; @@ -300,7 +300,7 @@ if ( destroy ) destroy( memory, data, user ); - FREE( cur ); + FT_FREE( cur ); cur = next; } diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c index 4d1d197e7..09e6cd2e5 100644 --- a/src/cache/ftccache.c +++ b/src/cache/ftccache.c @@ -210,7 +210,7 @@ if ( clazz->node_done ) clazz->node_done( node, cache ); - FREE( node ); + FT_FREE( node ); /* check, just in case of general corruption :-) */ if ( manager->num_nodes == 0 ) @@ -355,7 +355,7 @@ /* no need to report an error; we'll simply keep using the same */ /* buckets number / size */ - if ( ALLOC_ARRAY( new_buckets, new_size, FTC_Node ) ) + if ( FT_NEW_ARRAY( new_buckets, new_size ) ) return; for ( i = 0; i < cache->size; i++ ) @@ -379,7 +379,7 @@ } if ( cache->buckets ) - FREE( cache->buckets ); + FT_FREE( cache->buckets ); cache->buckets = new_buckets; cache->size = new_size; @@ -400,7 +400,7 @@ cache->nodes = 0; cache->size = FTC_PRIMES_MIN; - if ( ALLOC_ARRAY( cache->buckets, cache->size, FTC_Node ) ) + if ( FT_NEW_ARRAY( cache->buckets, cache->size ) ) goto Exit; /* now, initialize the lru list of families for this cache */ @@ -425,7 +425,7 @@ memory, &cache->families ); if ( error ) - FREE( cache->buckets ); + FT_FREE( cache->buckets ); } Exit: @@ -463,7 +463,7 @@ if ( clazz->node_done ) clazz->node_done( node, cache ); - FREE( node ); + FT_FREE( node ); node = next; } cache->buckets[i] = NULL; @@ -488,7 +488,7 @@ ftc_cache_clear( cache ); - FREE( cache->buckets ); + FT_FREE( cache->buckets ); cache->size = 0; if ( cache->families ) @@ -583,7 +583,7 @@ FTC_Node node; - if ( ALLOC( node, clazz->node_size ) ) + if ( FT_ALLOC( node, clazz->node_size ) ) goto Exit; node->fam_index = (FT_UShort) family->fam_index; @@ -593,7 +593,7 @@ error = clazz->node_init( node, query, cache ); if ( error ) { - FREE( node ); + FT_FREE( node ); goto Exit; } diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c index 9d100b035..14c9df159 100644 --- a/src/cache/ftcmanag.c +++ b/src/cache/ftcmanag.c @@ -336,7 +336,7 @@ ftc_family_table_done( FTC_FamilyTable table, FT_Memory memory ) { - FREE( table->entries ); + FT_FREE( table->entries ); table->free = 0; table->count = 0; table->size = 0; @@ -370,8 +370,7 @@ new_size = 65534; } - if ( REALLOC_ARRAY( table->entries, old_size, new_size, - FTC_FamilyEntryRec ) ) + if ( FT_RENEW_ARRAY( table->entries, old_size, new_size ) ) return error; table->size = new_size; @@ -464,7 +463,7 @@ memory = library->memory; - if ( ALLOC( manager, sizeof ( *manager ) ) ) + if ( FT_NEW( manager ) ) goto Exit; if ( max_faces == 0 ) @@ -508,7 +507,7 @@ { FT_LruList_Destroy( manager->faces_list ); FT_LruList_Destroy( manager->sizes_list ); - FREE( manager ); + FT_FREE( manager ); } return error; @@ -538,7 +537,7 @@ if ( cache ) { cache->clazz->cache_done( cache ); - FREE( cache ); + FT_FREE( cache ); manager->caches[idx] = 0; } } @@ -553,7 +552,7 @@ FT_LruList_Destroy( manager->sizes_list ); manager->sizes_list = 0; - FREE( manager ); + FT_FREE( manager ); } @@ -716,7 +715,7 @@ goto Exit; } - if ( !ALLOC( cache, clazz->cache_size ) ) + if ( !FT_ALLOC( cache, clazz->cache_size ) ) { cache->manager = manager; cache->memory = memory; @@ -734,7 +733,7 @@ if ( clazz->cache_done ) clazz->cache_done( cache ); - FREE( cache ); + FT_FREE( cache ); goto Exit; } } diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c index 3755b3747..4b7525148 100644 --- a/src/cache/ftcsbits.c +++ b/src/cache/ftcsbits.c @@ -95,8 +95,8 @@ size = (FT_ULong)( pitch * bitmap->rows ); - if ( !ALLOC( sbit->buffer, size ) ) - MEM_Copy( sbit->buffer, bitmap->buffer, size ); + if ( !FT_ALLOC( sbit->buffer, size ) ) + FT_MEM_COPY( sbit->buffer, bitmap->buffer, size ); return error; } @@ -112,7 +112,7 @@ for ( ; count > 0; sbit++, count-- ) - FREE( sbit->buffer ); + FT_FREE( sbit->buffer ); ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache ); } diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c index c2bae6720..e91fbdaba 100644 --- a/src/cache/ftlru.c +++ b/src/cache/ftlru.c @@ -40,7 +40,7 @@ return FTC_Err_Invalid_Argument; *alist = NULL; - if ( !ALLOC( list, clazz->list_size ) ) + if ( !FT_ALLOC( list, clazz->list_size ) ) { /* initialize common fields */ list->clazz = clazz; @@ -56,7 +56,7 @@ if ( clazz->list_done ) clazz->list_done( list ); - FREE( list ); + FT_FREE( list ); } } @@ -85,7 +85,7 @@ if ( clazz->list_done ) clazz->list_done( list ); - FREE( list ); + FT_FREE( list ); } @@ -112,7 +112,7 @@ if ( clazz->node_done ) clazz->node_done( node, list->data ); - FREE( node ); + FT_FREE( node ); node = next; } @@ -233,20 +233,20 @@ *plast = NULL; list->num_nodes--; - FREE( last ); + FT_FREE( last ); goto Exit; } } /* otherwise, simply allocate a new node */ - if ( ALLOC( node, clazz->node_size ) ) + if ( FT_ALLOC( node, clazz->node_size ) ) goto Exit; node->key = key; error = clazz->node_init( node, key, list->data ); if ( error ) { - FREE( node ); + FT_FREE( node ); goto Exit; } @@ -286,7 +286,7 @@ if ( clazz->node_done ) clazz->node_done( node, list->data ); - FREE( node ); + FT_FREE( node ); list->num_nodes--; break; } @@ -327,7 +327,7 @@ if ( clazz->node_done ) clazz->node_done( node, list ); - FREE( node ); + FT_FREE( node ); } else pnode = &(*pnode)->next; diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index 5082cd4ae..fb150d117 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -262,11 +262,11 @@ if ( len >= buffer_max ) len = buffer_max - 1; - MEM_Copy( buffer, gname, len ); + FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } - FREE ( gname ); + FT_FREE ( gname ); error = CFF_Err_Ok; Exit: @@ -411,7 +411,7 @@ result = strcmp( glyph_name, name ); if ( sid > 390 ) - FREE( name ); + FT_FREE( name ); if ( !result ) return i; diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index d73db3d79..7ffc99afd 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -356,7 +356,7 @@ /* clear everything */ - MEM_Set( decoder, 0, sizeof ( *decoder ) ); + FT_MEM_SET( decoder, 0, sizeof ( *decoder ) ); /* initialize builder */ CFF_Builder_Init( &decoder->builder, face, size, slot, hinting ); diff --git a/src/cff/cffload.c b/src/cff/cffload.c index 057348f88..d4b334274 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -1091,7 +1091,7 @@ FT_UShort count; - MEM_Set( idx, 0, sizeof ( *idx ) ); + FT_MEM_SET( idx, 0, sizeof ( *idx ) ); idx->stream = stream; if ( !FT_READ_USHORT( count ) && @@ -1113,8 +1113,8 @@ idx->off_size = offsize; data_size = (FT_ULong)( count + 1 ) * offsize; - if ( ALLOC_ARRAY( idx->offsets, count + 1, FT_ULong ) || - FT_FRAME_ENTER( data_size ) ) + if ( FT_NEW_ARRAY( idx->offsets, count + 1 ) || + FT_FRAME_ENTER( data_size ) ) goto Exit; poff = idx->offsets; @@ -1148,7 +1148,7 @@ Exit: if ( error ) - FREE( idx->offsets ); + FT_FREE( idx->offsets ); return error; } @@ -1166,8 +1166,8 @@ if ( idx->bytes ) FT_FRAME_RELEASE( idx->bytes ); - FREE( idx->offsets ); - MEM_Set( idx, 0, sizeof ( *idx ) ); + FT_FREE( idx->offsets ); + FT_MEM_SET( idx, 0, sizeof ( *idx ) ); } } @@ -1184,7 +1184,7 @@ *table = 0; - if ( idx->count > 0 && !ALLOC_ARRAY( t, idx->count + 1, FT_Byte* ) ) + if ( idx->count > 0 && !FT_NEW_ARRAY( t, idx->count + 1 ) ) { old_offset = 1; for ( n = 0; n <= idx->count; n++ ) @@ -1298,9 +1298,9 @@ if ( error ) goto Exit; - if ( !ALLOC( name, byte_len + 1 ) ) + if ( !FT_ALLOC( name, byte_len + 1 ) ) { - MEM_Copy( name, bytes, byte_len ); + FT_MEM_COPY( name, bytes, byte_len ); name[byte_len] = 0; } CFF_Forget_Element( idx, &bytes ); @@ -1333,9 +1333,9 @@ len = (FT_UInt)strlen( adobe_name ); - if ( !ALLOC( name, len + 1 ) ) + if ( !FT_ALLOC( name, len + 1 ) ) { - MEM_Copy( name, adobe_name, len ); + FT_MEM_COPY( name, adobe_name, len ); name[len] = 0; } @@ -1490,8 +1490,8 @@ FT_Memory memory = stream->memory; - FREE( encoding->codes ); - FREE( encoding->sids ); + FT_FREE( encoding->codes ); + FT_FREE( encoding->sids ); encoding->format = 0; encoding->offset = 0; encoding->codes = 0; @@ -1506,7 +1506,7 @@ FT_Memory memory = stream->memory; - FREE( charset->sids ); + FT_FREE( charset->sids ); charset->format = 0; charset->offset = 0; charset->sids = 0; @@ -1540,7 +1540,7 @@ /* Allocate memory for sids. */ - if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) ) + if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; /* assign the .notdef glyph */ @@ -1622,11 +1622,11 @@ } /* Allocate memory for sids. */ - if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) ) + if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; /* Copy the predefined charset into the allocated memory. */ - MEM_Copy( charset->sids, cff_isoadobe_charset, + FT_MEM_COPY( charset->sids, cff_isoadobe_charset, num_glyphs * sizeof ( FT_UShort ) ); break; @@ -1641,11 +1641,11 @@ } /* Allocate memory for sids. */ - if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) ) + if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; /* Copy the predefined charset into the allocated memory. */ - MEM_Copy( charset->sids, cff_expert_charset, + FT_MEM_COPY( charset->sids, cff_expert_charset, num_glyphs * sizeof ( FT_UShort ) ); break; @@ -1660,11 +1660,11 @@ } /* Allocate memory for sids. */ - if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) ) + if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; /* Copy the predefined charset into the allocated memory. */ - MEM_Copy( charset->sids, cff_expertsubset_charset, + FT_MEM_COPY( charset->sids, cff_expertsubset_charset, num_glyphs * sizeof ( FT_UShort ) ); break; @@ -1682,7 +1682,7 @@ if ( charset->sids ) { if ( charset->sids ) - FREE( charset->sids ); + FT_FREE( charset->sids ); charset->format = 0; charset->offset = 0; charset->sids = 0; @@ -1717,8 +1717,8 @@ /* Allocate memory for sids/codes -- there are at most 256 sids/codes */ /* for an encoding. */ - if ( ALLOC( encoding->sids, 256 * sizeof ( FT_UShort ) ) || - ALLOC( encoding->codes, 256 * sizeof ( FT_UShort ) ) ) + if ( FT_NEW_ARRAY( encoding->sids, 256 ) || + FT_NEW_ARRAY( encoding->codes, 256 ) ) goto Exit; /* Zero out the code to gid/sid mappings. */ @@ -1866,7 +1866,7 @@ { case 0: /* First, copy the code to SID mapping. */ - MEM_Copy( encoding->sids, cff_standard_encoding, + FT_MEM_COPY( encoding->sids, cff_standard_encoding, 256 * sizeof ( FT_UShort ) ); /* Construct code to GID mapping from code */ @@ -1897,7 +1897,7 @@ case 1: /* First, copy the code to SID mapping. */ - MEM_Copy( encoding->sids, cff_expert_encoding, + FT_MEM_COPY( encoding->sids, cff_expert_encoding, 256 * sizeof ( FT_UShort ) ); /* Construct code to GID mapping from code to SID mapping */ @@ -1941,10 +1941,10 @@ if ( encoding->sids || encoding->codes ) { if ( encoding->sids ) - FREE( encoding->sids ); + FT_FREE( encoding->sids ); if ( encoding->codes ) - FREE( encoding->codes ); + FT_FREE( encoding->codes ); charset->format = 0; charset->offset = 0; @@ -1974,7 +1974,7 @@ CFF_Parser_Init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); /* set defaults */ - MEM_Set( top, 0, sizeof ( *top ) ); + FT_MEM_SET( top, 0, sizeof ( *top ) ); top->underline_position = -100; top->underline_thickness = 50; @@ -1999,7 +1999,7 @@ if ( top->private_offset && top->private_size ) { /* set defaults */ - MEM_Set( priv, 0, sizeof ( *priv ) ); + FT_MEM_SET( priv, 0, sizeof ( *priv ) ); priv->blue_shift = 7; priv->blue_fuzz = 1; @@ -2051,7 +2051,7 @@ if ( subfont ) { cff_done_index( &subfont->local_subrs_index ); - FREE( subfont->local_subrs ); + FT_FREE( subfont->local_subrs ); } } @@ -2080,7 +2080,7 @@ CFF_FontRecDict dict; - MEM_Set( font, 0, sizeof ( *font ) ); + FT_MEM_SET( font, 0, sizeof ( *font ) ); font->stream = stream; font->memory = memory; @@ -2159,7 +2159,7 @@ /* allocate & read each font dict independently */ font->num_subfonts = fd_index.count; - if ( ALLOC_ARRAY( sub, fd_index.count, CFF_SubFontRec ) ) + if ( FT_NEW_ARRAY( sub, fd_index.count ) ) goto Fail_CID; /* setup pointer table */ @@ -2259,7 +2259,7 @@ for ( idx = 0; idx < font->num_subfonts; idx++ ) CFF_Done_SubFont( memory, font->subfonts[idx] ); - FREE( font->subfonts ); + FT_FREE( font->subfonts ); } CFF_Done_Encoding( &font->encoding, font->stream ); @@ -2269,8 +2269,8 @@ CFF_Done_FD_Select( &font->fd_select, font->stream ); - FREE( font->global_subrs ); - FREE( font->font_name ); + FT_FREE( font->global_subrs ); + FT_FREE( font->font_name ); } diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 500c7e14e..84a7c5079 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -116,7 +116,7 @@ FT_UInt n, count; - MEM_Set( &priv, 0, sizeof ( priv ) ); + FT_MEM_SET( &priv, 0, sizeof ( priv ) ); count = priv.num_blue_values = cpriv->num_blue_values; for ( n = 0; n < count; n++ ) @@ -236,9 +236,9 @@ FT_Int len = (FT_Int)strlen( source ); - if ( !ALLOC( result, len + 1 ) ) + if ( !FT_ALLOC( result, len + 1 ) ) { - MEM_Copy( result, source, len ); + FT_MEM_COPY( result, source, len ); result[len] = 0; } @@ -391,7 +391,7 @@ FT_UInt flags; - if ( ALLOC( cff, sizeof ( *cff ) ) ) + if ( FT_NEW( cff ) ) goto Exit; face->extra.data = cff; @@ -517,7 +517,7 @@ root->num_charmaps = face->num_charmaps; /* allocate table of pointers */ - if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) ) + if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) ) goto Exit; for ( n = 0; n < root->num_charmaps; n++, charmap++ ) @@ -569,7 +569,7 @@ if ( cff ) { CFF_Done_Font( cff ); - FREE( face->extra.data ); + FT_FREE( face->extra.data ); } } } diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c index 65a49c8d9..4c1888384 100644 --- a/src/cff/cffparse.c +++ b/src/cff/cffparse.c @@ -68,7 +68,7 @@ FT_UInt code, void* object ) { - MEM_Set( parser, 0, sizeof ( *parser ) ); + FT_MEM_SET( parser, 0, sizeof ( *parser ) ); parser->top = parser->stack; parser->object_code = code; diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index fd1a0a4b4..e87d9df24 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -89,7 +89,7 @@ /* the charstrings are encoded (stupid!) */ /* load the charstrings, then execute it */ - if ( ALLOC( charstring, glyph_len ) ) + if ( FT_ALLOC( charstring, glyph_len ) ) goto Exit; if ( !FT_STREAM_READ_AT( cid->data_offset + off1, charstring, glyph_len ) ) @@ -109,7 +109,7 @@ glyph_len - cs_offset ); } - FREE( charstring ); + FT_FREE( charstring ); } Exit: diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 31e421bd3..44073dd44 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -248,7 +248,7 @@ FT_Int n; - if ( ALLOC_ARRAY( cid->font_dicts, num_dicts, CID_FontDict ) ) + if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) ) goto Exit; cid->num_dicts = (FT_UInt)num_dicts; @@ -400,7 +400,7 @@ FT_ULong* offsets = 0; - if ( ALLOC_ARRAY( face->subrs, cid->num_dicts, CID_SubrsRec ) ) + if ( FT_NEW_ARRAY( face->subrs, cid->num_dicts ) ) goto Exit; subr = face->subrs; @@ -419,7 +419,7 @@ FT_UInt new_max = ( num_subrs + 1 + 3 ) & -4; - if ( REALLOC_ARRAY( offsets, max_offsets, new_max, FT_ULong ) ) + if ( FT_RENEW_ARRAY( offsets, max_offsets, new_max ) ) goto Fail; max_offsets = new_max; @@ -440,8 +440,8 @@ /* allocate, and read them */ data_len = offsets[num_subrs] - offsets[0]; - if ( ALLOC_ARRAY( subr->code, num_subrs + 1, FT_Byte* ) || - ALLOC( subr->code[0], data_len ) ) + if ( FT_NEW_ARRAY( subr->code, num_subrs + 1 ) || + FT_ALLOC( subr->code[0], data_len ) ) goto Fail; if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) || @@ -475,7 +475,7 @@ } Exit: - FREE( offsets ); + FT_FREE( offsets ); return error; Fail: @@ -484,11 +484,11 @@ for ( n = 0; n < cid->num_dicts; n++ ) { if ( face->subrs[n].code ) - FREE( face->subrs[n].code[0] ); + FT_FREE( face->subrs[n].code[0] ); - FREE( face->subrs[n].code ); + FT_FREE( face->subrs[n].code ); } - FREE( face->subrs ); + FT_FREE( face->subrs ); } goto Exit; } @@ -500,7 +500,7 @@ { FT_UNUSED( face ); - MEM_Set( loader, 0, sizeof ( *loader ) ); + FT_MEM_SET( loader, 0, sizeof ( *loader ) ); } diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index fde6c9a54..dd611e2b0 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -209,29 +209,29 @@ if ( subr->code ) { - FREE( subr->code[0] ); - FREE( subr->code ); + FT_FREE( subr->code[0] ); + FT_FREE( subr->code ); } } - FREE( face->subrs ); + FT_FREE( face->subrs ); } /* release FontInfo strings */ - FREE( info->version ); - FREE( info->notice ); - FREE( info->full_name ); - FREE( info->family_name ); - FREE( info->weight ); + FT_FREE( info->version ); + FT_FREE( info->notice ); + FT_FREE( info->full_name ); + FT_FREE( info->family_name ); + FT_FREE( info->weight ); /* release font dictionaries */ - FREE( cid->font_dicts ); + FT_FREE( cid->font_dicts ); cid->num_dicts = 0; /* release other strings */ - FREE( cid->cid_font_name ); - FREE( cid->registry ); - FREE( cid->ordering ); + FT_FREE( cid->cid_font_name ); + FT_FREE( cid->registry ); + FT_FREE( cid->ordering ); face->root.family_name = 0; face->root.style_name = 0; diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index e35eba799..946adc521 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -62,7 +62,7 @@ FT_Int buff_len; - MEM_Set( parser, 0, sizeof ( *parser ) ); + FT_MEM_SET( parser, 0, sizeof ( *parser ) ); psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory ); parser->stream = stream; @@ -95,7 +95,7 @@ /* fill input buffer */ buff_len -= 256; if ( buff_len > 0 ) - MEM_Move( buffer, limit, buff_len ); + FT_MEM_MOVE( buffer, limit, buff_len ); p = buffer + buff_len; diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c index 571af4099..db7fb8fa3 100644 --- a/src/pcf/pcfdriver.c +++ b/src/pcf/pcfdriver.c @@ -246,8 +246,8 @@ THE SOFTWARE. FT_Memory memory = FT_FACE_MEMORY( face ); - FREE( face->encodings ); - FREE( face->metrics ); + FT_FREE( face->encodings ); + FT_FREE( face->metrics ); /* free properties */ { @@ -258,19 +258,19 @@ THE SOFTWARE. { prop = &face->properties[i]; - FREE( prop->name ); + FT_FREE( prop->name ); if ( prop->isString ) - FREE( prop->value ); + FT_FREE( prop->value ); } - FREE( face->properties ); + FT_FREE( face->properties ); } - FREE( face->toc.tables ); - FREE( face->root.family_name ); - FREE( face->root.available_sizes ); - FREE( face->charset_encoding ); - FREE( face->charset_registry ); + FT_FREE( face->toc.tables ); + FT_FREE( face->root.family_name ); + FT_FREE( face->root.available_sizes ); + FT_FREE( face->charset_encoding ); + FT_FREE( face->charset_registry ); FT_TRACE4(( "DONE_FACE!!!\n" )); @@ -462,7 +462,7 @@ THE SOFTWARE. /* XXX: to do: are there cases that need repadding the bitmap? */ bytes = bitmap->pitch * bitmap->rows; - if ( ALLOC( bitmap->buffer, bytes ) ) + if ( FT_ALLOC( bitmap->buffer, bytes ) ) goto Exit; if ( FT_STREAM_SEEK( metric->bits ) || diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c index 91032ee1a..cfe555def 100644 --- a/src/pcf/pcfread.c +++ b/src/pcf/pcfread.c @@ -105,7 +105,7 @@ THE SOFTWARE. if ( toc->version != PCF_FILE_VERSION ) return PCF_Err_Invalid_File_Format; - if ( ALLOC( face->toc.tables, toc->count * sizeof ( PCF_TableRec ) ) ) + if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) ) return PCF_Err_Out_Of_Memory; tables = face->toc.tables; @@ -145,7 +145,7 @@ THE SOFTWARE. return PCF_Err_Ok; Exit: - FREE( face->toc.tables ); + FT_FREE( face->toc.tables ); return error; } @@ -383,7 +383,7 @@ THE SOFTWARE. FT_TRACE4(( "get_prop: nprop = %d\n", nprops )); - if ( ALLOC( props, nprops * sizeof ( PCF_ParsePropertyRec ) ) ) + if ( FT_NEW_ARRAY( props, nprops ) ) goto Bail; for ( i = 0; i < nprops; i++ ) @@ -420,22 +420,21 @@ THE SOFTWARE. FT_TRACE4(( "get_prop: string_size = %ld\n", string_size )); - if ( ALLOC( strings, string_size * sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( strings, string_size ) ) goto Bail; error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size ); if ( error ) goto Bail; - if ( ALLOC( properties, nprops * sizeof ( PCF_PropertyRec ) ) ) + if ( FT_NEW_ARRAY( properties, nprops ) ) goto Bail; for ( i = 0; i < nprops; i++ ) { /* XXX: make atom */ - if ( ALLOC( properties[i].name, - ( strlen( strings + props[i].name ) + 1 ) * - sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( properties[i].name, + strlen( strings + props[i].name ) + 1 ) ) goto Bail; strcpy( properties[i].name,strings + props[i].name ); @@ -443,9 +442,8 @@ THE SOFTWARE. if ( props[i].isString ) { - if ( ALLOC( properties[i].value.atom, - ( strlen( strings + props[i].value ) + 1 ) * - sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( properties[i].value.atom, + strlen( strings + props[i].value ) + 1 ) ) goto Bail; strcpy( properties[i].value.atom, strings + props[i].value ); } @@ -456,14 +454,14 @@ THE SOFTWARE. face->properties = properties; face->nprops = nprops; - FREE( props ); - FREE( strings ); + FT_FREE( props ); + FT_FREE( strings ); return PCF_Err_Ok; Bail: - FREE( props ); - FREE( strings ); + FT_FREE( props ); + FT_FREE( strings ); return error; } @@ -516,7 +514,7 @@ THE SOFTWARE. face->nmetrics = nmetrics; - if ( ALLOC( face->metrics, nmetrics * sizeof ( PCF_MetricRec ) ) ) + if ( FT_NEW_ARRAY( face->metrics, nmetrics ) ) return PCF_Err_Out_Of_Memory; metrics = face->metrics; @@ -541,7 +539,7 @@ THE SOFTWARE. } if ( error ) - FREE( face->metrics ); + FT_FREE( face->metrics ); return error; } @@ -586,7 +584,7 @@ THE SOFTWARE. if ( nbitmaps != face->nmetrics ) return PCF_Err_Invalid_File_Format; - if ( ALLOC( offsets, nbitmaps * sizeof ( FT_ULong ) ) ) + if ( FT_NEW_ARRAY( offsets, nbitmaps ) ) return error; for ( i = 0; i < nbitmaps; i++ ) @@ -627,12 +625,12 @@ THE SOFTWARE. face->bitmapsFormat = format; - FREE ( offsets ); + FT_FREE ( offsets ); return error; Bail: - FREE ( offsets ); - FREE ( bitmaps ); + FT_FREE ( offsets ); + FT_FREE ( bitmaps ); return error; } @@ -693,7 +691,7 @@ THE SOFTWARE. nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 ); - if ( ALLOC( tmpEncoding, nencoding * sizeof ( PCF_EncodingRec ) ) ) + if ( FT_NEW_ARRAY( tmpEncoding, nencoding ) ) return PCF_Err_Out_Of_Memory; error = FT_Stream_EnterFrame( stream, 2 * nencoding ); @@ -723,7 +721,8 @@ THE SOFTWARE. } FT_Stream_ExitFrame( stream ); - if ( ALLOC( encoding, (--j) * sizeof ( PCF_EncodingRec ) ) ) + j--; + if ( FT_NEW_ARRAY( encoding, j ) ) goto Bail; for ( i = 0; i < j; i++ ) @@ -734,13 +733,13 @@ THE SOFTWARE. face->nencodings = j; face->encodings = encoding; - FREE( tmpEncoding ); + FT_FREE( tmpEncoding ); return error; Bail: - FREE( encoding ); - FREE( tmpEncoding ); + FT_FREE( encoding ); + FT_FREE( tmpEncoding ); return error; } @@ -957,7 +956,7 @@ THE SOFTWARE. int l = strlen( prop->value.atom ) + 1; - if ( ALLOC( root->family_name, l * sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( root->family_name, l ) ) goto Exit; strcpy( root->family_name, prop->value.atom ); } @@ -968,7 +967,7 @@ THE SOFTWARE. root->num_glyphs = face->nmetrics; root->num_fixed_sizes = 1; - if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) ) + if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) goto Exit; prop = pcf_find_property( face, "PIXEL_SIZE" ); @@ -1027,14 +1026,12 @@ THE SOFTWARE. if ( ( charset_registry->isString ) && ( charset_encoding->isString ) ) { - if ( ALLOC( face->charset_encoding, - ( strlen( charset_encoding->value.atom ) + 1 ) * - sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( face->charset_encoding, + strlen( charset_encoding->value.atom ) + 1 ) ) goto Exit; - if ( ALLOC( face->charset_registry, - ( strlen( charset_registry->value.atom ) + 1 ) * - sizeof ( char ) ) ) + if ( FT_NEW_ARRAY( face->charset_registry, + strlen( charset_registry->value.atom ) + 1 ) ) goto Exit; strcpy( face->charset_registry, charset_registry->value.atom ); diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index da00fc72a..6b32eef9b 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -62,8 +62,8 @@ table->memory = memory; - if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) || - ALLOC_ARRAY( table->lengths, count, FT_Byte* ) ) + if ( FT_NEW_ARRAY( table->elements, count ) || + FT_NEW_ARRAY( table->lengths, count ) ) goto Exit; table->max_elems = count; @@ -77,7 +77,7 @@ Exit: if ( error ) - FREE( table->elements ); + FT_FREE( table->elements ); return error; } @@ -110,15 +110,15 @@ /* allocate new base block */ - if ( ALLOC( table->block, new_size ) ) + if ( FT_ALLOC( table->block, new_size ) ) return error; /* copy elements and shift offsets */ if (old_base ) { - MEM_Copy( table->block, old_base, table->capacity ); + FT_MEM_COPY( table->block, old_base, table->capacity ); shift_elements( table, old_base ); - FREE( old_base ); + FT_FREE( old_base ); } table->capacity = new_size; @@ -187,7 +187,7 @@ /* add the object to the base block and adjust offset */ table->elements[idx] = table->block + table->cursor; table->lengths [idx] = length; - MEM_Copy( table->block + table->cursor, object, length ); + FT_MEM_COPY( table->block + table->cursor, object, length ); table->cursor += length; return PSaux_Err_Ok; @@ -221,13 +221,13 @@ if ( !old_base ) return; - if ( ALLOC( table->block, table->cursor ) ) + if ( FT_ALLOC( table->block, table->cursor ) ) return; - MEM_Copy( table->block, old_base, table->cursor ); + FT_MEM_COPY( table->block, old_base, table->cursor ); shift_elements( table, old_base ); table->capacity = table->cursor; - FREE( old_base ); + FT_FREE( old_base ); FT_UNUSED( error ); } @@ -241,9 +241,9 @@ if ( (FT_ULong)table->init == 0xDEADBEEFUL ) { - FREE( table->block ); - FREE( table->elements ); - FREE( table->lengths ); + FT_FREE( table->block ); + FT_FREE( table->elements ); + FT_FREE( table->lengths ); table->init = 0; } } @@ -735,11 +735,11 @@ } len = cur - *cursor; - if ( cur >= limit || ALLOC( result, len + 1 ) ) + if ( cur >= limit || FT_ALLOC( result, len + 1 ) ) return 0; /* now copy the string */ - MEM_Copy( result, *cursor, len ); + FT_MEM_COPY( result, *cursor, len ); result[len] = '\0'; *cursor = cur; return result; @@ -867,10 +867,10 @@ /* with synthetic fonts, it's possible to find a field twice */ break; - if ( ALLOC( string, len + 1 ) ) + if ( FT_ALLOC( string, len + 1 ) ) goto Exit; - MEM_Copy( string, cur, len ); + FT_MEM_COPY( string, cur, len ); string[len] = 0; *(FT_String**)q = string; diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c index 2588f698f..3bfeac59a 100644 --- a/src/psaux/t1cmap.c +++ b/src/psaux/t1cmap.c @@ -268,7 +268,7 @@ count = face->type1.num_glyphs; - if ( !ALLOC_ARRAY( cmap->pairs, count, T1_CMapUniPairRec ) ) + if ( !FT_NEW_ARRAY( cmap->pairs, count ) ) { FT_UInt n, new_count; T1_CMapUniPair pair; @@ -298,7 +298,7 @@ if ( new_count == 0 ) { /* there are no unicode characters in here !! */ - FREE( cmap->pairs ); + FT_FREE( cmap->pairs ); error = FT_Err_Invalid_Argument; } else @@ -307,7 +307,7 @@ /* one.. */ if ( new_count != count && new_count < count/2 ) { - (void)REALLOC_ARRAY( cmap->pairs, count, new_count, T1_CMapUniPairRec ); + (void)FT_RENEW_ARRAY( cmap->pairs, count, new_count ); error = 0; } @@ -331,7 +331,7 @@ FT_Face face = FT_CMAP_FACE(cmap); FT_Memory memory = FT_FACE_MEMORY(face); - FREE( cmap->pairs ); + FT_FREE( cmap->pairs ); cmap->num_pairs = 0; } diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index 0c33e1fef..ccda54d08 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -1117,7 +1117,7 @@ FT_Bool hinting, T1_Decoder_Callback parse_callback ) { - MEM_Set( decoder, 0, sizeof ( *decoder ) ); + FT_MEM_SET( decoder, 0, sizeof ( *decoder ) ); /* retrieve PSNames interface from list of current modules */ { diff --git a/src/pshinter/pshalgo1.c b/src/pshinter/pshalgo1.c index c09260b42..faca3812d 100644 --- a/src/pshinter/pshalgo1.c +++ b/src/pshinter/pshalgo1.c @@ -53,12 +53,12 @@ psh1_hint_table_done( PSH1_Hint_Table table, FT_Memory memory ) { - FREE( table->zones ); + FT_FREE( table->zones ); table->num_zones = 0; table->zone = 0; - FREE( table->sort ); - FREE( table->hints ); + FT_FREE( table->sort ); + FT_FREE( table->hints ); table->num_hints = 0; table->max_hints = 0; table->sort_global = 0; @@ -176,9 +176,9 @@ /* allocate our tables */ - if ( ALLOC_ARRAY( table->sort, 2 * count, PSH1_Hint ) || - ALLOC_ARRAY( table->hints, count, PSH1_HintRec ) || - ALLOC_ARRAY( table->zones, 2 * count + 1, PSH1_ZoneRec ) ) + if ( FT_NEW_ARRAY( table->sort, 2 * count ) || + FT_NEW_ARRAY( table->hints, count ) || + FT_NEW_ARRAY( table->zones, 2 * count + 1 ) ) goto Exit; table->max_hints = count; diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c index 35f18afa3..1ddce48ac 100644 --- a/src/pshinter/pshalgo2.c +++ b/src/pshinter/pshalgo2.c @@ -54,12 +54,12 @@ psh2_hint_table_done( PSH2_Hint_Table table, FT_Memory memory ) { - FREE( table->zones ); + FT_FREE( table->zones ); table->num_zones = 0; table->zone = 0; - FREE( table->sort ); - FREE( table->hints ); + FT_FREE( table->sort ); + FT_FREE( table->hints ); table->num_hints = 0; table->max_hints = 0; table->sort_global = 0; @@ -173,9 +173,9 @@ /* allocate our tables */ - if ( ALLOC_ARRAY( table->sort, 2 * count, PSH2_Hint ) || - ALLOC_ARRAY( table->hints, count, PSH2_HintRec ) || - ALLOC_ARRAY( table->zones, 2 * count + 1, PSH2_ZoneRec ) ) + if ( FT_NEW_ARRAY( table->sort, 2 * count ) || + FT_NEW_ARRAY( table->hints, count ) || + FT_NEW_ARRAY( table->zones, 2 * count + 1 ) ) goto Exit; table->max_hints = count; @@ -814,8 +814,8 @@ psh2_hint_table_done( &glyph->hint_tables[1], memory ); psh2_hint_table_done( &glyph->hint_tables[0], memory ); - FREE( glyph->points ); - FREE( glyph->contours ); + FT_FREE( glyph->points ); + FT_FREE( glyph->contours ); glyph->num_points = 0; glyph->num_contours = 0; @@ -866,10 +866,8 @@ memory = globals->memory; /* allocate and setup points + contours arrays */ - if ( ALLOC_ARRAY( glyph->points, outline->n_points, - PSH2_PointRec ) || - ALLOC_ARRAY( glyph->contours, outline->n_contours, - PSH2_ContourRec ) ) + if ( FT_NEW_ARRAY( glyph->points, outline->n_points ) || + FT_NEW_ARRAY( glyph->contours, outline->n_contours ) ) goto Exit; glyph->num_points = outline->n_points; @@ -1512,10 +1510,10 @@ if ( ps2_debug_glyph ) { psh2_glyph_done( ps2_debug_glyph ); - FREE( ps2_debug_glyph ); + FT_FREE( ps2_debug_glyph ); } - if ( ALLOC( glyph, sizeof ( *glyph ) ) ) + if ( FT_NEW( glyph ) ) return error; ps2_debug_glyph = glyph; diff --git a/src/pshinter/pshglob.c b/src/pshinter/pshglob.c index 03a722da2..21bd2a291 100644 --- a/src/pshinter/pshglob.c +++ b/src/pshinter/pshglob.c @@ -568,7 +568,7 @@ globals->blues.family_top.count = 0; globals->blues.family_bottom.count = 0; - FREE( globals ); + FT_FREE( globals ); #ifdef DEBUG_HINTER ps_debug_globals = 0; @@ -586,7 +586,7 @@ FT_Error error; - if ( !ALLOC( globals, sizeof ( *globals ) ) ) + if ( !FT_NEW( globals ) ) { FT_UInt count; FT_Short* read; diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c index eb72563ad..a67896656 100644 --- a/src/pshinter/pshrec.c +++ b/src/pshinter/pshrec.c @@ -46,7 +46,7 @@ ps_hint_table_done( PS_Hint_Table table, FT_Memory memory ) { - FREE( table->hints ); + FT_FREE( table->hints ); table->num_hints = 0; table->max_hints = 0; } @@ -67,7 +67,7 @@ { /* try to grow the table */ new_max = ( new_max + 7 ) & -8; - if ( !REALLOC_ARRAY( table->hints, old_max, new_max, PS_HintRec ) ) + if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) ) table->max_hints = new_max; } return error; @@ -120,7 +120,7 @@ ps_mask_done( PS_Mask mask, FT_Memory memory ) { - FREE( mask->bytes ); + FT_FREE( mask->bytes ); mask->num_bits = 0; mask->max_bits = 0; mask->end_point = 0; @@ -141,7 +141,7 @@ if ( new_max > old_max ) { new_max = ( new_max + 7 ) & -8; - if ( !REALLOC_ARRAY( mask->bytes, old_max, new_max, FT_Byte ) ) + if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) ) mask->max_bits = new_max * 8; } return error; @@ -218,7 +218,7 @@ for ( ; count > 0; count--, mask++ ) ps_mask_done( mask, memory ); - FREE( table->masks ); + FT_FREE( table->masks ); table->num_masks = 0; table->max_masks = 0; } @@ -238,7 +238,7 @@ if ( new_max > old_max ) { new_max = ( new_max + 7 ) & -8; - if ( !REALLOC_ARRAY( table->masks, old_max, new_max, PS_MaskRec ) ) + if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) ) table->max_masks = new_max; } return error; diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 5b3e2de4a..e5c0769ab 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -154,7 +154,7 @@ table->num_maps = 0; table->maps = 0; - if ( !ALLOC_ARRAY( table->maps, num_glyphs, PS_UniMap ) ) + if ( !FT_NEW_ARRAY( table->maps, num_glyphs ) ) { FT_UInt n; FT_UInt count; @@ -185,14 +185,14 @@ /* now, compress the table a bit */ count = (FT_UInt)( map - table->maps ); - if ( count > 0 && REALLOC( table->maps, + if ( count > 0 && FT_REALLOC( table->maps, num_glyphs * sizeof ( PS_UniMap ), count * sizeof ( PS_UniMap ) ) ) count = 0; if ( count == 0 ) { - FREE( table->maps ); + FT_FREE( table->maps ); if ( !error ) error = PSnames_Err_Invalid_Argument; /* no unicode chars here! */ } diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 7d0ad9143..298675eae 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -186,8 +186,8 @@ #endif /* _STANDALONE_ */ -#ifndef MEM_Set -#define MEM_Set( d, s, c ) memset( d, s, c ) +#ifndef FT_MEM_SET +#define FT_MEM_SET( d, s, c ) memset( d, s, c ) #endif @@ -3146,7 +3146,7 @@ *araster = &the_raster; - MEM_Set( &the_raster, sizeof ( the_raster ), 0 ); + FT_MEM_SET( &the_raster, sizeof ( the_raster ), 0 ); ft_black_init( &the_raster ); return 0; @@ -3173,7 +3173,7 @@ *araster = 0; - if ( !ALLOC( raster, sizeof ( *raster ) ) ) + if ( !FT_NEW( raster ) ) { raster->memory = memory; ft_black_init( raster ); @@ -3189,7 +3189,7 @@ ft_black_done( TRaster_Instance* raster ) { FT_Memory memory = (FT_Memory)raster->memory; - FREE( raster ); + FT_FREE( raster ); } diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c index ed2402c0f..96e798010 100644 --- a/src/raster/ftrend1.c +++ b/src/raster/ftrend1.c @@ -86,7 +86,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - MEM_Set( cbox, 0, sizeof ( *cbox ) ); + FT_MEM_SET( cbox, 0, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -153,7 +153,7 @@ /* release old bitmap buffer */ if ( slot->flags & FT_GLYPH_OWN_BITMAP ) { - FREE( bitmap->buffer ); + FT_FREE( bitmap->buffer ); slot->flags &= ~FT_GLYPH_OWN_BITMAP; } @@ -175,7 +175,7 @@ bitmap->rows = height; bitmap->pitch = pitch; - if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) + if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->flags |= FT_GLYPH_OWN_BITMAP; diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 07fbd84a6..cc291e83a 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -103,7 +103,7 @@ if ( len >= buffer_max ) len = buffer_max - 1; - MEM_Copy( buffer, gname, len ); + FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } @@ -153,7 +153,7 @@ FT_UInt len = name->stringLength/2; FT_Error error; - if ( !ALLOC( result, len+1 ) ) + if ( !FT_ALLOC( result, len+1 ) ) { FT_String* r = (FT_String*)result; FT_Byte* p = (FT_Byte*) name->string; @@ -176,9 +176,9 @@ FT_Error error; FT_String* result; - if ( !ALLOC( result, len+1 ) ) + if ( !FT_ALLOC( result, len+1 ) ) { - MEM_Copy( result, name->string, len ); + FT_MEM_COPY( result, name->string, len ); result[len] = '\0'; } goto Exit; diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 82dfb3d89..8aff67ee2 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -131,7 +131,7 @@ len = (FT_UInt)rec->stringLength / 2; - if ( MEM_Alloc( string, len + 1 ) ) + if ( FT_MEM_ALLOC( string, len + 1 ) ) return NULL; for ( m = 0; m < len; m ++ ) @@ -140,10 +140,10 @@ else { len = rec->stringLength; - if ( MEM_Alloc( string, len + 1 ) ) + if ( FT_MEM_ALLOC( string, len + 1 ) ) return NULL; - MEM_Copy( string, rec->string, len ); + FT_MEM_COPY( string, rec->string, len ); } string[len] = '\0'; @@ -458,7 +458,7 @@ root->num_charmaps = face->num_charmaps; /* allocate table of pointers */ - if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) ) + if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) ) goto Exit; for ( n = 0; n < root->num_charmaps; n++, charmap++ ) @@ -497,9 +497,7 @@ #endif root->num_fixed_sizes = face->num_sbit_strikes; - if ( ALLOC_ARRAY( root->available_sizes, - face->num_sbit_strikes, - FT_Bitmap_Size ) ) + if ( FT_NEW_ARRAY( root->available_sizes, face->num_sbit_strikes ) ) goto Exit; for ( n = 0 ; n < face->num_sbit_strikes ; n++ ) @@ -637,15 +635,15 @@ } /* freeing the kerning table */ - FREE( face->kern_pairs ); + FT_FREE( face->kern_pairs ); face->num_kern_pairs = 0; /* freeing the collection table */ - FREE( face->ttc_header.offsets ); + FT_FREE( face->ttc_header.offsets ); face->ttc_header.count = 0; /* freeing table directory */ - FREE( face->dir_tables ); + FT_FREE( face->dir_tables ); face->num_tables = 0; /* freeing the character mapping tables */ @@ -658,27 +656,27 @@ sfnt->free_charmap( face, &face->charmaps[n].cmap ); } - FREE( face->charmaps ); + FT_FREE( face->charmaps ); face->num_charmaps = 0; - FREE( face->root.charmaps ); + FT_FREE( face->root.charmaps ); face->root.num_charmaps = 0; face->root.charmap = 0; /* freeing the horizontal metrics */ - FREE( face->horizontal.long_metrics ); - FREE( face->horizontal.short_metrics ); + FT_FREE( face->horizontal.long_metrics ); + FT_FREE( face->horizontal.short_metrics ); /* freeing the vertical ones, if any */ if ( face->vertical_info ) { - FREE( face->vertical.long_metrics ); - FREE( face->vertical.short_metrics ); + FT_FREE( face->vertical.long_metrics ); + FT_FREE( face->vertical.short_metrics ); face->vertical_info = 0; } /* freeing the gasp table */ - FREE( face->gasp.gaspRanges ); + FT_FREE( face->gasp.gaspRanges ); face->gasp.numRanges = 0; /* freeing the name table */ @@ -688,13 +686,13 @@ sfnt->free_hdmx( face ); /* freeing family and style name */ - FREE( face->root.family_name ); - FREE( face->root.style_name ); + FT_FREE( face->root.family_name ); + FT_FREE( face->root.style_name ); /* freeing sbit size table */ face->root.num_fixed_sizes = 0; if ( face->root.available_sizes ) - FREE( face->root.available_sizes ); + FT_FREE( face->root.available_sizes ); face->sfnt = 0; } diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index 6512e065a..7a583915c 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -144,7 +144,7 @@ cmap0 = &cmap->c.cmap0; if ( FT_READ_USHORT( cmap0->language ) || - ALLOC( cmap0->glyphIdArray, 256L ) || + FT_ALLOC( cmap0->glyphIdArray, 256L ) || FT_STREAM_READ( cmap0->glyphIdArray, 256L ) ) goto Fail; @@ -158,7 +158,7 @@ /* allocate subheader keys */ - if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, FT_UShort ) || + if ( FT_NEW_ARRAY( cmap2->subHeaderKeys, 256 ) || FT_FRAME_ENTER( 2L + 512L ) ) goto Fail; @@ -180,12 +180,10 @@ cmap2->numGlyphId = l = (FT_UShort)( ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2 ); - if ( ALLOC_ARRAY( cmap2->subHeaders, - num_SH + 1, - TT_CMap2SubHeaderRec ) || - FT_FRAME_ENTER( ( num_SH + 1 ) * 8L ) ) + if ( FT_NEW_ARRAY( cmap2->subHeaders, num_SH + 1 ) || + FT_FRAME_ENTER( ( num_SH + 1 ) * 8L ) ) { - FREE( cmap2->subHeaderKeys ); + FT_FREE( cmap2->subHeaderKeys ); goto Fail; } @@ -207,11 +205,11 @@ /* load glyph IDs */ - if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, FT_UShort ) || - FT_FRAME_ENTER( l * 2L ) ) + if ( FT_NEW_ARRAY( cmap2->glyphIdArray, l ) || + FT_FRAME_ENTER( l * 2L ) ) { - FREE( cmap2->subHeaders ); - FREE( cmap2->subHeaderKeys ); + FT_FREE( cmap2->subHeaders ); + FT_FREE( cmap2->subHeaderKeys ); goto Fail; } @@ -244,9 +242,7 @@ /* load segments */ - if ( ALLOC_ARRAY( cmap4->segments, - num_Seg, - TT_CMap4SegmentRec ) || + if ( FT_NEW_ARRAY( cmap4->segments, num_Seg ) || FT_FRAME_ENTER( ( num_Seg * 4 + 1 ) * 2L ) ) goto Fail; @@ -273,10 +269,10 @@ /* load IDs */ - if ( ALLOC_ARRAY( cmap4->glyphIdArray, l, FT_UShort ) || - FT_FRAME_ENTER( l * 2L ) ) + if ( FT_NEW_ARRAY( cmap4->glyphIdArray, l ) || + FT_FRAME_ENTER( l * 2L ) ) { - FREE( cmap4->segments ); + FT_FREE( cmap4->segments ); goto Fail; } @@ -305,8 +301,8 @@ l = cmap6->entryCount; - if ( ALLOC_ARRAY( cmap6->glyphIdArray, l, FT_Short ) || - FT_FRAME_ENTER( l * 2L ) ) + if ( FT_NEW_ARRAY( cmap6->glyphIdArray, l ) || + FT_FRAME_ENTER( l * 2L ) ) goto Fail; for ( i = 0; i < l; i++ ) @@ -338,8 +334,8 @@ n = cmap8_12->nGroups; - if ( ALLOC_ARRAY( cmap8_12->groups, n, TT_CMapGroupRec ) || - FT_FRAME_ENTER( n * 3 * 4L ) ) + if ( FT_NEW_ARRAY( cmap8_12->groups, n ) || + FT_FRAME_ENTER( n * 3 * 4L ) ) goto Fail; groups = cmap8_12->groups; @@ -374,8 +370,8 @@ n = cmap10->numChars; - if ( ALLOC_ARRAY( cmap10->glyphs, n, FT_Short ) || - FT_FRAME_ENTER( n * 2L ) ) + if ( FT_NEW_ARRAY( cmap10->glyphs, n ) || + FT_FRAME_ENTER( n * 2L ) ) goto Fail; for ( j = 0; j < n; j++ ) @@ -429,34 +425,34 @@ switch ( cmap->format ) { case 0: - FREE( cmap->c.cmap0.glyphIdArray ); + FT_FREE( cmap->c.cmap0.glyphIdArray ); break; case 2: - FREE( cmap->c.cmap2.subHeaderKeys ); - FREE( cmap->c.cmap2.subHeaders ); - FREE( cmap->c.cmap2.glyphIdArray ); + FT_FREE( cmap->c.cmap2.subHeaderKeys ); + FT_FREE( cmap->c.cmap2.subHeaders ); + FT_FREE( cmap->c.cmap2.glyphIdArray ); break; case 4: - FREE( cmap->c.cmap4.segments ); - FREE( cmap->c.cmap4.glyphIdArray ); + FT_FREE( cmap->c.cmap4.segments ); + FT_FREE( cmap->c.cmap4.glyphIdArray ); cmap->c.cmap4.segCountX2 = 0; break; case 6: - FREE( cmap->c.cmap6.glyphIdArray ); + FT_FREE( cmap->c.cmap6.glyphIdArray ); cmap->c.cmap6.entryCount = 0; break; case 8: case 12: - FREE( cmap->c.cmap8_12.groups ); + FT_FREE( cmap->c.cmap8_12.groups ); cmap->c.cmap8_12.nGroups = 0; break; case 10: - FREE( cmap->c.cmap10.glyphs ); + FT_FREE( cmap->c.cmap10.glyphs ); cmap->c.cmap10.numChars = 0; break; diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index c47a67766..8e6995c4b 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -221,10 +221,8 @@ goto Exit; /* now read the offsets of each font in the file */ - if ( ALLOC_ARRAY( face->ttc_header.offsets, - face->ttc_header.count, - FT_ULong ) || - FT_FRAME_ENTER( face->ttc_header.count * 4L ) ) + if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) || + FT_FRAME_ENTER( face->ttc_header.count * 4L ) ) goto Exit; for ( n = 0; n < face->ttc_header.count; n++ ) @@ -312,9 +310,7 @@ face->num_tables = sfnt->num_tables; - if ( ALLOC_ARRAY( face->dir_tables, - face->num_tables, - TT_TableRec ) ) + if ( FT_NEW_ARRAY( face->dir_tables, face->num_tables ) ) goto Exit; if ( FT_FRAME_ENTER( face->num_tables * 16L ) ) @@ -749,8 +745,8 @@ goto Exit; } - if ( ALLOC_ARRAY( *longs, num_longs, TT_LongMetricsRec ) || - ALLOC_ARRAY( *shorts, num_shorts, TT_ShortMetrics ) ) + if ( FT_NEW_ARRAY( *longs, num_longs ) || + FT_NEW_ARRAY( *shorts, num_shorts ) ) goto Exit; if ( FT_FRAME_ENTER( table_len ) ) @@ -987,7 +983,7 @@ storageSize = (FT_ULong)(table_len - storageOffset); /* Allocate the array of name records. */ - if ( ALLOC( names->names, + if ( FT_ALLOC( names->names, names->numNameRecords*sizeof(TT_NameEntryRec) + storageSize ) || FT_FRAME_ENTER( names->numNameRecords * 12L ) ) goto Exit; @@ -1097,10 +1093,10 @@ /* free strings table */ - FREE( names->names ); + FT_FREE( names->names ); /* free strings storage */ - FREE( names->storage ); + FT_FREE( names->storage ); names->numNameRecords = 0; names->format = 0; @@ -1171,9 +1167,7 @@ goto Exit; /* reserve space in face table for cmap tables */ - if ( ALLOC_ARRAY( face->charmaps, - cmap_dir.numCMaps, - TT_CharMapRec ) ) + if ( FT_NEW_ARRAY( face->charmaps, cmap_dir.numCMaps ) ) goto Exit; face->num_charmaps = cmap_dir.numCMaps; @@ -1534,8 +1528,8 @@ num_ranges = face->gasp.numRanges; FT_TRACE3(( "number of ranges = %d\n", num_ranges )); - if ( ALLOC_ARRAY( gaspranges, num_ranges, TT_GaspRangeRec ) || - FT_FRAME_ENTER( num_ranges * 4L ) ) + if ( FT_NEW_ARRAY( gaspranges, num_ranges ) || + FT_FRAME_ENTER( num_ranges * 4L ) ) goto Exit; face->gasp.gaspRanges = gaspranges; @@ -1638,8 +1632,8 @@ FT_FRAME_EXIT(); /* allocate array of kerning pairs */ - if ( ALLOC_ARRAY( face->kern_pairs, num_pairs, TT_Kern0_PairRec ) || - FT_FRAME_ENTER( 6L * num_pairs ) ) + if ( FT_NEW_ARRAY( face->kern_pairs, num_pairs ) || + FT_FRAME_ENTER( 6L * num_pairs ) ) goto Exit; pair = face->kern_pairs; @@ -1763,7 +1757,7 @@ if ( hdmx->version != 0 ) goto Exit; - if ( ALLOC_ARRAY( hdmx->records, hdmx->num_records, TT_HdmxEntryRec ) ) + if ( FT_NEW_ARRAY( hdmx->records, hdmx->num_records ) ) goto Exit; num_glyphs = face->root.num_glyphs; @@ -1781,7 +1775,7 @@ FT_READ_BYTE( cur->max_width ) ) goto Exit; - if ( ALLOC( cur->widths, num_glyphs ) || + if ( FT_ALLOC( cur->widths, num_glyphs ) || FT_STREAM_READ( cur->widths, num_glyphs ) ) goto Exit; @@ -1817,9 +1811,9 @@ for ( n = 0; n < face->hdmx.num_records; n++ ) - FREE( face->hdmx.records[n].widths ); + FT_FREE( face->hdmx.records[n].widths ); - FREE( face->hdmx.records ); + FT_FREE( face->hdmx.records ); face->hdmx.num_records = 0; } } diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c index 5219b5de6..0743364b5 100644 --- a/src/sfnt/ttpost.c +++ b/src/sfnt/ttpost.c @@ -185,8 +185,8 @@ FT_Int n; - if ( ALLOC_ARRAY ( glyph_indices, num_glyphs, FT_UShort ) || - FT_FRAME_ENTER( num_glyphs * 2L ) ) + if ( FT_NEW_ARRAY ( glyph_indices, num_glyphs ) || + FT_FRAME_ENTER( num_glyphs * 2L ) ) goto Fail; for ( n = 0; n < num_glyphs; n++ ) @@ -222,7 +222,7 @@ FT_UShort n; - if ( ALLOC_ARRAY( name_strings, num_names, FT_Char* ) ) + if ( FT_NEW_ARRAY( name_strings, num_names ) ) goto Fail; for ( n = 0; n < num_names; n++ ) @@ -230,9 +230,9 @@ FT_UInt len; - if ( FT_READ_BYTE ( len ) || - ALLOC_ARRAY( name_strings[n], len + 1, FT_Char ) || - FT_STREAM_READ ( name_strings[n], len ) ) + if ( FT_READ_BYTE ( len ) || + FT_NEW_ARRAY( name_strings[n], len + 1 ) || + FT_STREAM_READ ( name_strings[n], len ) ) goto Fail1; name_strings[n][len] = '\0'; @@ -258,12 +258,12 @@ for ( n = 0; n < num_names; n++ ) - FREE( name_strings[n] ); + FT_FREE( name_strings[n] ); } Fail: - FREE( name_strings ); - FREE( glyph_indices ); + FT_FREE( name_strings ); + FT_FREE( glyph_indices ); Exit: return error; @@ -292,7 +292,7 @@ goto Exit; } - if ( ALLOC ( offset_table, num_glyphs ) || + if ( FT_ALLOC ( offset_table, num_glyphs ) || FT_STREAM_READ( offset_table, num_glyphs ) ) goto Fail; @@ -326,7 +326,7 @@ return SFNT_Err_Ok; Fail: - FREE( offset_table ); + FT_FREE( offset_table ); Exit: return error; @@ -394,13 +394,13 @@ FT_UShort n; - FREE( table->glyph_indices ); + FT_FREE( table->glyph_indices ); table->num_glyphs = 0; for ( n = 0; n < table->num_names; n++ ) - FREE( table->glyph_names[n] ); + FT_FREE( table->glyph_names[n] ); - FREE( table->glyph_names ); + FT_FREE( table->glyph_names ); table->num_names = 0; } break; @@ -410,7 +410,7 @@ TT_Post_25 table = &names->names.format_25; - FREE( table->offsets ); + FT_FREE( table->offsets ); table->num_glyphs = 0; } break; diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index fcb1d9e14..cd8b13014 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -271,7 +271,7 @@ /* Allocate glyph offsets table if needed */ if ( load_offsets ) { - if ( ALLOC_ARRAY( range->glyph_offsets, count, FT_ULong ) ) + if ( FT_NEW_ARRAY( range->glyph_offsets, count ) ) goto Exit; size = count * 4L; @@ -280,8 +280,8 @@ size = count * 2L; /* Allocate glyph codes table and access frame */ - if ( ALLOC_ARRAY ( range->glyph_codes, count, FT_UShort ) || - FT_FRAME_ENTER( size ) ) + if ( FT_NEW_ARRAY ( range->glyph_codes, count ) || + FT_FRAME_ENTER( size ) ) goto Exit; for ( n = 0; n < count; n++ ) @@ -340,9 +340,8 @@ size_elem = large ? 4 : 2; - if ( ALLOC_ARRAY( range->glyph_offsets, - num_glyphs, FT_ULong ) || - FT_FRAME_ENTER( num_glyphs * size_elem ) ) + if ( FT_NEW_ARRAY( range->glyph_offsets, num_glyphs ) || + FT_FRAME_ENTER( num_glyphs * size_elem ) ) goto Exit; for ( n = 0; n < num_glyphs; n++ ) @@ -479,7 +478,7 @@ } /* allocate the strikes table */ - if ( ALLOC_ARRAY( face->sbit_strikes, num_strikes, TT_SBit_StrikeRec ) ) + if ( FT_NEW_ARRAY( face->sbit_strikes, num_strikes ) ) goto Exit; face->num_sbit_strikes = num_strikes; @@ -520,9 +519,7 @@ FT_ULong count2 = strike->num_ranges; - if ( ALLOC_ARRAY( strike->sbit_ranges, - strike->num_ranges, - TT_SBit_RangeRec ) ) + if ( FT_NEW_ARRAY( strike->sbit_ranges, strike->num_ranges ) ) goto Exit; /* read each range */ @@ -610,14 +607,14 @@ { /* release the glyph offsets and codes tables */ /* where appropriate */ - FREE( range->glyph_offsets ); - FREE( range->glyph_codes ); + FT_FREE( range->glyph_offsets ); + FT_FREE( range->glyph_codes ); } } - FREE( strike->sbit_ranges ); + FT_FREE( strike->sbit_ranges ); strike->num_ranges = 0; } - FREE( face->sbit_strikes ); + FT_FREE( face->sbit_strikes ); } face->num_sbit_strikes = 0; } @@ -993,7 +990,7 @@ { line = (FT_Byte*)map->buffer; - MEM_Move( line, line + count * line_len, + FT_MEM_MOVE( line, line + count * line_len, ( rows - count ) * line_len ); metrics->height = (FT_Byte)( metrics->height - count ); @@ -1270,7 +1267,7 @@ if ( size == 0 ) goto Exit; /* exit successfully! */ - if ( ALLOC( map->buffer, size ) ) + if ( FT_ALLOC( map->buffer, size ) ) goto Exit; } @@ -1303,8 +1300,8 @@ FT_UShort num_components, count; - if ( FT_READ_USHORT( num_components ) || - ALLOC_ARRAY( components, num_components, TT_SBit_ComponentRec ) ) + if ( FT_READ_USHORT( num_components ) || + FT_NEW_ARRAY( components, num_components ) ) goto Exit; count = num_components; @@ -1354,7 +1351,7 @@ } Fail_Memory: - FREE( components ); + FT_FREE( components ); } Exit: @@ -1430,7 +1427,7 @@ /* clear the bitmap & load the bitmap */ if ( face->root.glyph->flags & FT_GLYPH_OWN_BITMAP ) - FREE( map->buffer ); + FT_FREE( map->buffer ); map->rows = map->pitch = map->width = 0; diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index cc47c18f6..bba31ad7d 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -145,8 +145,8 @@ #endif /* _STANDALONE_ */ -#ifndef MEM_Set -#define MEM_Set( d, s, c ) memset( d, s, c ) +#ifndef FT_MEM_SET +#define FT_MEM_SET( d, s, c ) memset( d, s, c ) #endif /* define this to dump debugging information */ @@ -1288,7 +1288,7 @@ if ( coverage ) #if 1 - MEM_Set( p + spans->x, (unsigned char)coverage, spans->len ); + FT_MEM_SET( p + spans->x, (unsigned char)coverage, spans->len ); #else /* 1 */ { q = p + spans->x; @@ -2057,7 +2057,7 @@ *araster = (FT_Raster)&the_raster; - MEM_Set( &the_raster, 0, sizeof ( the_raster ) ); + FT_MEM_SET( &the_raster, 0, sizeof ( the_raster ) ); #ifdef GRAYS_USE_GAMMA grays_init_gamma( (PRaster)*araster ); @@ -2085,7 +2085,7 @@ *araster = 0; - if ( !ALLOC( raster, sizeof ( TRaster ) ) ) + if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) ) { raster->memory = memory; *araster = (FT_Raster)raster; @@ -2105,7 +2105,7 @@ FT_Memory memory = (FT_Memory)((PRaster)raster)->memory; - FREE( raster ); + FT_FREE( raster ); } #endif /* _STANDALONE_ */ diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index 5e59b46e0..80c4c99e8 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -85,7 +85,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - MEM_Set( cbox, 0, sizeof ( *cbox ) ); + FT_MEM_SET( cbox, 0, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -142,7 +142,7 @@ /* release old bitmap buffer */ if ( slot->flags & FT_GLYPH_OWN_BITMAP ) { - FREE( bitmap->buffer ); + FT_FREE( bitmap->buffer ); slot->flags &= ~FT_GLYPH_OWN_BITMAP; } @@ -154,7 +154,7 @@ bitmap->rows = height; bitmap->pitch = pitch; - if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) + if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->flags |= FT_GLYPH_OWN_BITMAP; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 17610091d..4ff468b68 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -145,10 +145,10 @@ #define cur_to_org( n, zone ) \ - MEM_Copy( (zone)->org, (zone)->cur, (n) * sizeof ( FT_Vector ) ) + FT_MEM_COPY( (zone)->org, (zone)->cur, (n) * sizeof ( FT_Vector ) ) #define org_to_cur( n, zone ) \ - MEM_Copy( (zone)->cur, (zone)->org, (n) * sizeof ( FT_Vector ) ) + FT_MEM_COPY( (zone)->cur, (zone)->org, (n) * sizeof ( FT_Vector ) ) /*************************************************************************/ @@ -339,7 +339,7 @@ slot->control_len = n_ins; slot->control_data = load->instructions; - MEM_Copy( load->instructions, stream->cursor, n_ins ); + FT_MEM_COPY( load->instructions, stream->cursor, n_ins ); } #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ @@ -1515,7 +1515,7 @@ goto Exit; } - MEM_Set( &loader, 0, sizeof ( loader ) ); + FT_MEM_SET( &loader, 0, sizeof ( loader ) ); /* update the glyph zone bounds */ { diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index f9c64253a..a2333b1da 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -385,7 +385,7 @@ FT_Memory memory ) { /* free composite load stack */ - FREE( exec->loadStack ); + FT_FREE( exec->loadStack ); exec->loadSize = 0; /* points zone */ @@ -393,22 +393,22 @@ exec->maxContours = 0; /* free stack */ - FREE( exec->stack ); + FT_FREE( exec->stack ); exec->stackSize = 0; /* free call stack */ - FREE( exec->callStack ); + FT_FREE( exec->callStack ); exec->callSize = 0; exec->callTop = 0; /* free glyph code range */ - FREE( exec->glyphIns ); + FT_FREE( exec->glyphIns ); exec->glyphSize = 0; exec->size = NULL; exec->face = NULL; - FREE( exec ); + FT_FREE( exec ); return TT_Err_Ok; } @@ -446,7 +446,7 @@ exec->memory = memory; exec->callSize = 32; - if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TT_CallRec ) ) + if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) ) goto Fail_Memory; /* all values in the context are set to 0 already, but this is */ @@ -512,8 +512,8 @@ if ( *size < new_max ) { - FREE( *buff ); - if ( ALLOC( *buff, new_max * multiplier ) ) + FT_FREE( *buff ); + if ( FT_ALLOC( *buff, new_max * multiplier ) ) return error; *size = new_max; } @@ -776,7 +776,7 @@ /* allocate object */ - if ( ALLOC( exec, sizeof ( *exec ) ) ) + if ( FT_NEW( exec ) ) goto Exit; /* initialize it */ @@ -792,7 +792,7 @@ return driver->context; Fail: - FREE( exec ); + FT_FREE( exec ); return 0; } @@ -3846,7 +3846,7 @@ K = CUR.stack[CUR.args - L]; - MEM_Move( &CUR.stack[CUR.args - L ], + FT_MEM_MOVE( &CUR.stack[CUR.args - L ], &CUR.stack[CUR.args - L + 1], ( L - 1 ) * sizeof ( FT_Long ) ); diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index ac04ca283..6da86e1ef 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -71,10 +71,10 @@ FT_Memory memory = zone->memory; - FREE( zone->contours ); - FREE( zone->tags ); - FREE( zone->cur ); - FREE( zone->org ); + FT_FREE( zone->contours ); + FT_FREE( zone->tags ); + FT_FREE( zone->cur ); + FT_FREE( zone->org ); zone->max_points = zone->n_points = 0; zone->max_contours = zone->n_contours = 0; @@ -114,13 +114,13 @@ if ( maxPoints > 0 ) maxPoints += 2; - MEM_Set( zone, 0, sizeof ( *zone ) ); + FT_MEM_SET( zone, 0, sizeof ( *zone ) ); zone->memory = memory; - if ( ALLOC_ARRAY( zone->org, maxPoints * 2, FT_F26Dot6 ) || - ALLOC_ARRAY( zone->cur, maxPoints * 2, FT_F26Dot6 ) || - ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) || - ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) ) + if ( FT_NEW_ARRAY( zone->org, maxPoints * 2 ) || + FT_NEW_ARRAY( zone->cur, maxPoints * 2 ) || + FT_NEW_ARRAY( zone->tags, maxPoints ) || + FT_NEW_ARRAY( zone->contours, maxContours ) ) { TT_Done_GlyphZone( zone ); } @@ -241,11 +241,11 @@ sfnt->done_face( face ); /* freeing the locations table */ - FREE( face->glyph_locations ); + FT_FREE( face->glyph_locations ); face->num_locations = 0; /* freeing the CVT */ - FREE( face->cvt ); + FT_FREE( face->cvt ); face->cvt_size = 0; /* freeing the programs */ @@ -326,19 +326,10 @@ } /* allocate function defs, instruction defs, cvt, and storage area */ - if ( ALLOC_ARRAY( size->function_defs, - size->max_function_defs, - TT_DefRecord ) || - - ALLOC_ARRAY( size->instruction_defs, - size->max_instruction_defs, - TT_DefRecord ) || - - ALLOC_ARRAY( size->cvt, - size->cvt_size, FT_Long ) || - - ALLOC_ARRAY( size->storage, - size->storage_size, FT_Long ) ) + if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) || + FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || + FT_NEW_ARRAY( size->cvt, size->cvt_size ) || + FT_NEW_ARRAY( size->storage, size->storage_size ) ) goto Fail_Memory; @@ -480,18 +471,18 @@ size->debug = FALSE; } - FREE( size->cvt ); + FT_FREE( size->cvt ); size->cvt_size = 0; /* free storage area */ - FREE( size->storage ); + FT_FREE( size->storage ); size->storage_size = 0; /* twilight zone */ TT_Done_GlyphZone( &size->twilight ); - FREE( size->function_defs ); - FREE( size->instruction_defs ); + FT_FREE( size->function_defs ); + FT_FREE( size->instruction_defs ); size->num_function_defs = 0; size->max_function_defs = 0; diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index 6cdbd2dc6..212d484ea 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -80,9 +80,7 @@ FT_TRACE2(( "(32bit offsets): %12d ", face->num_locations )); - if ( ALLOC_ARRAY( face->glyph_locations, - face->num_locations, - FT_Long ) ) + if ( FT_NEW_ARRAY( face->glyph_locations, face->num_locations ) ) goto Exit; if ( FT_FRAME_ENTER( face->num_locations * 4L ) ) @@ -105,9 +103,7 @@ FT_TRACE2(( "(16bit offsets): %12d ", face->num_locations )); - if ( ALLOC_ARRAY( face->glyph_locations, - face->num_locations, - FT_Long ) ) + if ( FT_NEW_ARRAY( face->glyph_locations, face->num_locations ) ) goto Exit; if ( FT_FRAME_ENTER( face->num_locations * 2L ) ) @@ -172,9 +168,7 @@ face->cvt_size = table_len / 2; - if ( ALLOC_ARRAY( face->cvt, - face->cvt_size, - FT_Short ) ) + if ( FT_NEW_ARRAY( face->cvt, face->cvt_size ) ) goto Exit; if ( FT_FRAME_ENTER( face->cvt_size * 2L ) ) diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c index 897d20c7d..4fd7b521f 100644 --- a/src/type1/t1afm.c +++ b/src/type1/t1afm.c @@ -39,9 +39,9 @@ T1_Done_AFM( FT_Memory memory, T1_AFM* afm ) { - FREE( afm->kern_pairs ); + FT_FREE( afm->kern_pairs ); afm->num_pairs = 0; - FREE( afm ); + FT_FREE( afm ); } @@ -83,7 +83,7 @@ /* copy glyph name to intermediate array */ - MEM_Copy( temp, *start, len ); + FT_MEM_COPY( temp, *start, len ); temp[len] = 0; /* lookup glyph name in face array */ @@ -192,8 +192,7 @@ goto Exit; /* allocate the pairs */ - if ( ALLOC( afm, sizeof ( *afm ) ) || - ALLOC_ARRAY( afm->kern_pairs, count, T1_Kern_Pair ) ) + if ( FT_NEW( afm ) || FT_NEW_ARRAY( afm->kern_pairs, count ) ) goto Exit; /* now, read each kern pair */ @@ -235,7 +234,7 @@ Exit: if ( error ) - FREE( afm ); + FT_FREE( afm ); FT_FRAME_EXIT(); diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 118c7d596..bae91042d 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -63,7 +63,7 @@ if (len >= buffer_max) len = buffer_max - 1; - MEM_Copy( buffer, gname, len ); + FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } diff --git a/src/type1/t1load.c b/src/type1/t1load.c index 299d90dad..40d8c5737 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -109,7 +109,7 @@ blend = face->blend; if ( !blend ) { - if ( ALLOC( blend, sizeof ( *blend ) ) ) + if ( FT_NEW( blend ) ) goto Exit; face->blend = blend; @@ -124,9 +124,9 @@ /* allocate the blend `private' and `font_info' dictionaries */ - if ( ALLOC_ARRAY( blend->font_infos[1], num_designs, PS_FontInfoRec ) || - ALLOC_ARRAY( blend->privates[1], num_designs, PS_PrivateRec ) || - ALLOC_ARRAY( blend->weight_vector, num_designs * 2, FT_Fixed ) ) + if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) || + FT_NEW_ARRAY( blend->privates[1], num_designs ) || + FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) ) goto Exit; blend->default_weight_vector = blend->weight_vector + num_designs; @@ -163,8 +163,7 @@ FT_UInt n; - if ( ALLOC_ARRAY( blend->design_pos[0], - num_designs * num_axis, FT_Fixed ) ) + if ( FT_NEW_ARRAY( blend->design_pos[0], num_designs * num_axis ) ) goto Exit; for ( n = 1; n < num_designs; n++ ) @@ -343,13 +342,13 @@ /* release design pos table */ - FREE( blend->design_pos[0] ); + FT_FREE( blend->design_pos[0] ); for ( n = 1; n < num_designs; n++ ) blend->design_pos[n] = 0; /* release blend `private' and `font info' dictionaries */ - FREE( blend->privates[1] ); - FREE( blend->font_infos[1] ); + FT_FREE( blend->privates[1] ); + FT_FREE( blend->font_infos[1] ); for ( n = 0; n < num_designs; n++ ) { @@ -358,12 +357,12 @@ } /* release weight vectors */ - FREE( blend->weight_vector ); + FT_FREE( blend->weight_vector ); blend->default_weight_vector = 0; /* release axis names */ for ( n = 0; n < num_axis; n++ ) - FREE( blend->axis_names[n] ); + FT_FREE( blend->axis_names[n] ); /* release design map */ for ( n = 0; n < num_axis; n++ ) @@ -371,11 +370,11 @@ PS_DesignMap dmap = blend->design_map + n; - FREE( dmap->design_points ); + FT_FREE( dmap->design_points ); dmap->num_points = 0; } - FREE( face->blend ); + FT_FREE( face->blend ); } } @@ -428,11 +427,11 @@ goto Exit; } - if ( ALLOC( blend->axis_names[n], len + 1 ) ) + if ( FT_ALLOC( blend->axis_names[n], len + 1 ) ) goto Exit; name = (FT_Byte*)blend->axis_names[n]; - MEM_Copy( name, token->start, len ); + FT_MEM_COPY( name, token->start, len ); name[len] = 0; } @@ -584,7 +583,7 @@ } /* allocate design map data */ - if ( ALLOC_ARRAY( map->design_points, num_points * 2, FT_Fixed ) ) + if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) ) goto Exit; map->blend_points = map->design_points + num_points; map->num_points = (FT_Byte)num_points; @@ -848,13 +847,13 @@ len = (FT_Int)( cur2 - cur ); if ( len > 0 ) { - if ( ALLOC( face->type1.font_name, len + 1 ) ) + if ( FT_ALLOC( face->type1.font_name, len + 1 ) ) { parser->root.error = error; return; } - MEM_Copy( face->type1.font_name, cur, len ); + FT_MEM_COPY( face->type1.font_name, cur, len ); face->type1.font_name[len] = '\0'; } parser->root.cursor = cur2; @@ -972,10 +971,10 @@ /* we use a T1_Table to store our charnames */ loader->num_chars = encode->num_chars = count; - if ( ALLOC_ARRAY( encode->char_index, count, FT_Short ) || - ALLOC_ARRAY( encode->char_name, count, FT_String* ) || - ( error = psaux->ps_table_funcs->init( - char_table, count, memory ) ) != 0 ) + if ( FT_NEW_ARRAY( encode->char_index, count ) || + FT_NEW_ARRAY( encode->char_name, count ) || + FT_SET_ERROR( psaux->ps_table_funcs->init( + char_table, count, memory ) ) ) { parser->root.error = error; return; @@ -1172,14 +1171,14 @@ /* t1_decrypt() shouldn't write to base -- make temporary copy */ - if ( ALLOC( temp, size ) ) + if ( FT_ALLOC( temp, size ) ) goto Fail; - MEM_Copy( temp, base, size ); + FT_MEM_COPY( temp, base, size ); psaux->t1_decrypt( temp, size, 4330 ); size -= face->type1.private_dict.lenIV; error = T1_Add_Table( table, idx, temp + face->type1.private_dict.lenIV, size ); - FREE( temp ); + FT_FREE( temp ); } else error = T1_Add_Table( table, idx, base, size ); @@ -1313,14 +1312,14 @@ /* t1_decrypt() shouldn't write to base -- make temporary copy */ - if ( ALLOC( temp, size ) ) + if ( FT_ALLOC( temp, size ) ) goto Fail; - MEM_Copy( temp, base, size ); + FT_MEM_COPY( temp, base, size ); psaux->t1_decrypt( temp, size, 4330 ); size -= face->type1.private_dict.lenIV; error = T1_Add_Table( code_table, n, temp + face->type1.private_dict.lenIV, size ); - FREE( temp ); + FT_FREE( temp ); } else error = T1_Add_Table( code_table, n, base, size ); @@ -1605,7 +1604,7 @@ { FT_UNUSED( face ); - MEM_Set( loader, 0, sizeof ( *loader ) ); + FT_MEM_SET( loader, 0, sizeof ( *loader ) ); loader->num_glyphs = 0; loader->num_chars = 0; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 6feeef8d9..b1515bd3d 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -208,28 +208,28 @@ PS_FontInfo info = &type1->font_info; - FREE( info->version ); - FREE( info->notice ); - FREE( info->full_name ); - FREE( info->family_name ); - FREE( info->weight ); + FT_FREE( info->version ); + FT_FREE( info->notice ); + FT_FREE( info->full_name ); + FT_FREE( info->family_name ); + FT_FREE( info->weight ); } /* release top dictionary */ - FREE( type1->charstrings_len ); - FREE( type1->charstrings ); - FREE( type1->glyph_names ); + FT_FREE( type1->charstrings_len ); + FT_FREE( type1->charstrings ); + FT_FREE( type1->glyph_names ); - FREE( type1->subrs ); - FREE( type1->subrs_len ); + FT_FREE( type1->subrs ); + FT_FREE( type1->subrs_len ); - FREE( type1->subrs_block ); - FREE( type1->charstrings_block ); - FREE( type1->glyph_names_block ); + FT_FREE( type1->subrs_block ); + FT_FREE( type1->charstrings_block ); + FT_FREE( type1->glyph_names_block ); - FREE( type1->encoding.char_index ); - FREE( type1->encoding.char_name ); - FREE( type1->font_name ); + FT_FREE( type1->encoding.char_index ); + FT_FREE( type1->encoding.char_name ); + FT_FREE( type1->font_name ); #ifndef T1_CONFIG_OPTION_NO_AFM /* release afm data if present */ @@ -238,7 +238,7 @@ #endif /* release unicode map, if any */ - FREE( face->unicode_map.maps ); + FT_FREE( face->unicode_map.maps ); face->unicode_map.num_maps = 0; face->root.family_name = 0; diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c index 93693f0a7..02df70327 100644 --- a/src/type1/t1parse.c +++ b/src/type1/t1parse.c @@ -193,7 +193,7 @@ else { /* read segment in memory */ - if ( ALLOC( parser->base_dict, size ) || + if ( FT_ALLOC( parser->base_dict, size ) || FT_STREAM_READ( parser->base_dict, size ) ) goto Exit; parser->base_len = size; @@ -221,7 +221,7 @@ Exit: if ( error && !parser->in_memory ) - FREE( parser->base_dict ); + FT_FREE( parser->base_dict ); return error; } @@ -234,11 +234,11 @@ /* always free the private dictionary */ - FREE( parser->private_dict ); + FT_FREE( parser->private_dict ); /* free the base dictionary only when we have a disk stream */ if ( !parser->in_memory ) - FREE( parser->base_dict ); + FT_FREE( parser->base_dict ); parser->root.funcs.done( &parser->root ); } @@ -314,7 +314,7 @@ } if ( FT_STREAM_SEEK( start_pos ) || - ALLOC( parser->private_dict, parser->private_len ) ) + FT_ALLOC( parser->private_dict, parser->private_len ) ) goto Fail; parser->private_len = 0; @@ -384,7 +384,7 @@ if ( parser->in_memory ) { /* note that we allocate one more byte to put a terminating `0' */ - if ( ALLOC( parser->private_dict, size + 1 ) ) + if ( FT_ALLOC( parser->private_dict, size + 1 ) ) goto Fail; parser->private_len = size; } @@ -408,7 +408,7 @@ hexa_value( cur[2] ) | hexa_value( cur[3] ) ) < 0 ) /* binary encoding -- `simply' copy the private dict */ - MEM_Copy( parser->private_dict, cur, size ); + FT_MEM_COPY( parser->private_dict, cur, size ); else { diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index b05a55dcf..02fcf7ee5 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -178,7 +178,7 @@ for ( ; cur < limit; cur++ ) fnt_font_done( cur, stream ); - FREE( face->fonts ); + FT_FREE( face->fonts ); face->num_fonts = 0; } @@ -260,8 +260,8 @@ goto Exit; } - if ( FT_STREAM_SEEK( font_offset ) || - ALLOC_ARRAY( face->fonts, font_count, FNT_FontRec ) ) + if ( FT_STREAM_SEEK( font_offset ) || + FT_NEW_ARRAY( face->fonts, font_count ) ) goto Exit; face->num_fonts = font_count; @@ -447,7 +447,7 @@ fnt_face_done_fonts( face ); - FREE( face->root.available_sizes ); + FT_FREE( face->root.available_sizes ); face->root.num_fixed_sizes = 0; } @@ -474,7 +474,7 @@ /* this didn't work, now try to load a single FNT font */ FNT_Font font; - if ( ALLOC( face->fonts, sizeof ( *face->fonts ) ) ) + if ( FT_NEW( face->fonts ) ) goto Exit; face->num_fonts = 1; @@ -511,8 +511,7 @@ root->style_flags |= FT_STYLE_FLAG_BOLD; /* Setup the `fixed_sizes' array */ - if ( ALLOC_ARRAY( root->available_sizes, face->num_fonts, - FT_Bitmap_Size ) ) + if ( FT_NEW_ARRAY( root->available_sizes, face->num_fonts ) ) goto Fail; root->num_fixed_sizes = face->num_fonts; @@ -677,7 +676,7 @@ bitmap->rows = font->header.pixel_height; bitmap->pixel_mode = ft_pixel_mode_mono; - if ( ALLOC( bitmap->buffer, pitch * bitmap->rows ) ) + if ( FT_ALLOC( bitmap->buffer, pitch * bitmap->rows ) ) goto Exit; column = (FT_Byte*)bitmap->buffer;