Cleanups.

This commit is contained in:
Werner Lemberg 2003-04-23 06:32:41 +00:00
parent 7dc281c88d
commit 2d117ea531
2 changed files with 48 additions and 35 deletions

View File

@ -84,7 +84,8 @@
* src/pcf/pcfdriver.c, src/pfr/pfrsbit.c, * src/pcf/pcfdriver.c, src/pfr/pfrsbit.c,
src/sfnt/ttsbit.c, src/type42/t42objs.c, src/winfonts/winfnt.c: src/sfnt/ttsbit.c, src/type42/t42objs.c, src/winfonts/winfnt.c:
* src/cache/ftlru.c: Fixed an invalid assertion check. * src/cache/ftlru.c (FT_LruList_Lookup): Fixed an invalid assertion
check.
* src/autohint/ahglyph.c (ah_outline_load): Add two scaling * src/autohint/ahglyph.c (ah_outline_load): Add two scaling
arguments. arguments.
@ -92,8 +93,8 @@
* src/autohint/ahhint.c (ah_hinter_load): Updated. * src/autohint/ahhint.c (ah_hinter_load): Updated.
* src/autohint/ahglobal.c (ah_hinter_compute_widths): Updated. * src/autohint/ahglobal.c (ah_hinter_compute_widths): Updated.
* src/cache/ftccache.c: Fixed small bug that could crash the cache * src/cache/ftccache.c (ftc_family_done): Fixed small bug that could
in rare circumstances (mostly with broken fonts). crash the cache in rare circumstances (mostly with broken fonts).
2003-03-15 David Turner <david@freetype.org> 2003-03-15 David Turner <david@freetype.org>
@ -119,9 +120,17 @@
Handle new environment variables. Handle new environment variables.
* docs/DEBUG.TXT: Updated. * docs/DEBUG.TXT: Updated.
* src/cache/ftccache.c, src/cache/ftccmap.c, src/cache/ftcsbits.c, Fixed the cache sub-system to correctly deal with out-of-memory
src/cache/ftlru.c: Fixed the cache sub-system to correctly deal with conditions.
out-of-memory conditions.
* src/cache/ftccache.c (ftc_node_destroy): Comment out generic
check.
(ftc_cache_lookup): Implement loop.
* src/cache/ftccmap.c: Define FT_COMPONENT.
* src/cache/ftcsbits.c (ftc_sbit_node_load): Handle
FT_Err_Out_Of_Memory.
* src/cache/ftlru.c: Include FT_INTERNAL_DEBUG_H.
(FT_LruList_Lookup): Implement loop.
* src/pfr/pfrobjs.c, src/pfr/pfrsbits.c: Fixing compiler warnings * src/pfr/pfrobjs.c, src/pfr/pfrsbits.c: Fixing compiler warnings
and a small memory leak. and a small memory leak.
@ -142,8 +151,9 @@
2003-02-25 Anthony Fok <anthony@thizlinux.com> 2003-02-25 Anthony Fok <anthony@thizlinux.com>
* src/cache/ftccmap.c: The cmap cache now supports UCS-4 charmaps * src/cache/ftccmap.c: Include FT_TRUETYPE_IDS_H.
when available in Asian fonts. (ftc_cmap_family_init): The cmap cache now
supports UCS-4 charmaps when available in Asian fonts.
* src/sfnt/ttload.c, src/base/ftobjs.c: Changed "asian" to "Asian" * src/sfnt/ttload.c, src/base/ftobjs.c: Changed "asian" to "Asian"
in comments. in comments.
@ -218,10 +228,10 @@
* src/pfr/pfrsbit.c: Removed compiler warnings. * src/pfr/pfrsbit.c: Removed compiler warnings.
* src/cache/ftccmap.c: Changed an FT_ERROR into an FT_TRACE1 since * src/cache/ftccmap.c (ftc_cmap_family_init): Changed an FT_ERROR
it caused "ftview" and others to dump too much junk when trying to into an FT_TRACE1 since it caused "ftview" and others to dump too
display a waterfall with a font without a Unicode charmap (e.g. much junk when trying to display a waterfall with a font without a
SYMBOL.TTF). Unicode charmap (e.g. SYMBOL.TTF).
Implemented FT_CONFIG_CHESTER_BLUE_SCALE, corresponding to the last Implemented FT_CONFIG_CHESTER_BLUE_SCALE, corresponding to the last
patch from David Chester, but with a much simpler (and saner) patch from David Chester, but with a much simpler (and saner)
@ -423,7 +433,7 @@
invalid values for large negative angle differences (resulting in invalid values for large negative angle differences (resulting in
incorrect stroker computations, among other things). incorrect stroker computations, among other things).
* src/cache/ftccache.c (ftc_node_unlink): Removing incorrect * src/cache/ftccache.c (ftc_node_hash_unlink): Removing incorrect
assertion, and changing code to avoid hash table size contraction. assertion, and changing code to avoid hash table size contraction.
* src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: Adding * src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: Adding

47
src/cache/ftccache.c vendored
View File

@ -4,7 +4,7 @@
/* */ /* */
/* The FreeType internal cache interface (body). */ /* The FreeType internal cache interface (body). */
/* */ /* */
/* Copyright 2000-2001, 2002 by */ /* Copyright 2000-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -196,7 +196,7 @@
FTC_Node* pold; FTC_Node* pold;
if ( old_index+1 <= FTC_HASH_INITIAL_SIZE ) if ( old_index + 1 <= FTC_HASH_INITIAL_SIZE )
goto Exit; goto Exit;
if ( p == 0 ) if ( p == 0 )
@ -567,24 +567,24 @@
manager = cache->manager; manager = cache->manager;
/* here's a small note explaining what's hapenning in the code below. /* here's a small note explaining what's happening in the code below.
* *
* we need to deal intelligently with out-of-memory (OOM) conditions * We need to deal intelligently with out-of-memory (OOM) conditions
* when trying to create a new family or cache node during the lookup. * when trying to create a new family or cache node during the lookup.
* *
* when an OOM is detected, we'll try to free one or more "old" nodes * When an OOM is detected, we try to free one or more "old" nodes
* from the cache, then try again. it may be necessary to do that several * from the cache, then try again. It may be necessary to do that
* times, so a loop is needed. * several times, so a loop is needed.
* *
* the local variable "free_count" holds the number of "old" nodes to * The local variable "free_count" holds the number of "old" nodes to
* discard on each attempt. it starts at 1 and doubles on each iteration. * discard on each attempt. It starts at 1 and doubles on each
* the loop stops when: * iteration. The loop stops when:
* *
* - a non-OOM error is detected * - a non-OOM error is detected
* - a succesful lookup is performed * - a succesful lookup is performed
* - there are no more unused nodes in the cache * - there are no more unused nodes in the cache
* *
* for the record, remember that all used nodes appear _before_ * For the record, remember that all used nodes appear _before_
* unused ones in the manager's MRU node list. * unused ones in the manager's MRU node list.
*/ */
@ -747,13 +747,14 @@
if ( error != FT_Err_Out_Of_Memory ) if ( error != FT_Err_Out_Of_Memory )
goto Exit; goto Exit;
/* there is not enough memory, try to release some unused nodes /* There is not enough memory; try to release some unused nodes
* from the cache to make room for a new one. * from the cache to make room for a new one.
*/ */
{ {
FT_UInt new_count; FT_UInt new_count;
new_count = 1 + free_count*2;
new_count = 1 + free_count * 2;
/* check overflow and bounds */ /* check overflow and bounds */
if ( new_count < free_count || free_count > manager->num_nodes ) if ( new_count < free_count || free_count > manager->num_nodes )
@ -763,22 +764,24 @@
/* try to remove "new_count" nodes from the list */ /* try to remove "new_count" nodes from the list */
{ {
FTC_Node first = manager->nodes_list; FTC_Node first = manager->nodes_list;
FTC_Node node; FTC_Node node;
if ( first == NULL ) /* empty list ! */
if ( first == NULL ) /* empty list! */
goto Exit; goto Exit;
/* go to last node - it's a circular list */ /* go to last node - it's a circular list */
node = first->mru_prev; node = first->mru_prev;
for ( ; node && new_count > 0; new_count-- ) for ( ; node && new_count > 0; new_count-- )
{ {
FTC_Node prev = node->mru_prev; FTC_Node prev = node->mru_prev;
/* used nodes always appear before unused one in the MRU
* list. if we find one here, we'd better stop right now /* Used nodes always appear before unused one in the MRU
* our iteration * list. If we find one here, we'd better stop right now
*/ * our iteration.
*/
if ( node->ref_count > 0 ) if ( node->ref_count > 0 )
{ {
/* if there are no unused nodes in the list, we'd better exit */ /* if there are no unused nodes in the list, we'd better exit */