LOCAL_FUNC FT_Error TT_New_GlyphZone(FT_Memory memory, FT_UShort maxPoints, FT_Short maxContours, TT_GlyphZone *zone) { FT_Error error; if(maxPoints > 0) { maxPoints += 2; } 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)) { TT_Done_GlyphZone(zone); } return error; }
/* return the glyph's control box */ static void ft_smooth_get_cbox( FT_Renderer render, FT_GlyphSlot slot, FT_BBox* cbox ) { MEM_Set( cbox, 0, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); }
/* loads the outline into the optimizer */ int AH_Optimizer_Init( AH_Optimizer* optimizer, AH_Outline* outline, FT_Memory memory ) { FT_Error error; MEM_Set( optimizer, 0, sizeof( *optimizer ) ); optimizer->outline = outline; optimizer->memory = memory; LOG( ( "initializing new optimizer\n" ) ); /* compute stems and springs */ error = optim_compute_stems( optimizer ) || optim_compute_springs( optimizer ); if ( error ) { goto Fail; } /* allocate stem positions history and configurations */ { int n, max_stems; max_stems = optimizer->num_hstems; if ( max_stems < optimizer->num_vstems ) { max_stems = optimizer->num_vstems; } if ( ALLOC_ARRAY( optimizer->positions, max_stems * AH_MAX_CONFIGS, FT_Pos ) ) { goto Fail; } optimizer->num_configs = 0; for ( n = 0; n < AH_MAX_CONFIGS; n++ ) optimizer->configs[n].positions = optimizer->positions + n * max_stems; } return error; Fail: AH_Optimizer_Done( optimizer ); return error; }
EXPORT_FUNC TT_Error TT_Alloc( ULong Size, void** P ) { Int i; if ( !P ) return TT_Err_Invalid_Argument; /* Also see below for another case of "invalid argument". */ if ( Size > 0 ) { if ( Size > ( UINT_MAX & ~0xFu ) ) *P = (void*)huge_alloc( Size ); else *P = (void*)malloc( Size ); if ( !*P ) return TT_Err_Out_Of_Memory; #ifndef TT_CONFIG_OPTION_THREAD_SAFE TTMemory_Allocated += Size; TTMemory_MaxAllocated += Size; #endif #ifdef DEBUG_MEMORY num_alloc++; i = 0; while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) i++; if ( i >= MAX_TRACKED_BLOCKS ) fail_alloc++; else { pointers[i].base = *P; pointers[i].size = Size; } #else if ( Size > ( UINT_MAX & ~0xFu ) ) { i = 0; while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) i++; if ( i >= MAX_TRACKED_BIGCHUNKS ) /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ return TT_Err_Invalid_Argument; else { pointers[i].base = *P; pointers[i].size = Size; } } #endif /* DEBUG_MEMORY */ if ( Size > ( UINT_MAX & ~0xFu ) ) { char TT_HUGE_PTR * p = (char TT_HUGE_PTR *) *P; ULong left = (ULong)Size; size_t toClear; while ( left ) { toClear = (left > 0xFF00) ? 0xFF00 : left; MEM_Set( p, 0, toClear ); left -= (ULong) toClear; p += toClear; } } else MEM_Set( *P, 0, Size ); } else *P = NULL; return TT_Err_Ok; }