Commit 2d117ea531013c588f109a464eea092dd5477cb4

Werner Lemberg 2003-04-23T06:32:41

Cleanups.

diff --git a/ChangeLog b/ChangeLog
index 1214c2f..f842f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -84,7 +84,8 @@
 	* src/pcf/pcfdriver.c, src/pfr/pfrsbit.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
 	arguments.
@@ -92,8 +93,8 @@
 	* src/autohint/ahhint.c (ah_hinter_load): Updated.
 	* src/autohint/ahglobal.c (ah_hinter_compute_widths): Updated.
 
-	* src/cache/ftccache.c: Fixed small bug that could crash the cache
-	in rare circumstances (mostly with broken fonts).
+	* src/cache/ftccache.c (ftc_family_done): Fixed small bug that could
+	crash the cache in rare circumstances (mostly with broken fonts).
 
 2003-03-15  David Turner  <david@freetype.org>
 
@@ -119,9 +120,17 @@
 	Handle new environment variables.
 	* docs/DEBUG.TXT: Updated.
 
-	* src/cache/ftccache.c, src/cache/ftccmap.c, src/cache/ftcsbits.c,
-	src/cache/ftlru.c: Fixed the cache sub-system to correctly deal with
-	out-of-memory conditions.
+	Fixed the cache sub-system to correctly deal with 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
 	and a small memory leak.
@@ -142,8 +151,9 @@
 
 2003-02-25  Anthony Fok  <anthony@thizlinux.com>
 
-	* src/cache/ftccmap.c: The cmap cache now supports UCS-4 charmaps
-	when available in Asian fonts.
+	* src/cache/ftccmap.c: Include FT_TRUETYPE_IDS_H.
+	(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"
 	in comments.
@@ -218,10 +228,10 @@
 
 	* src/pfr/pfrsbit.c: Removed compiler warnings.
 
-	* src/cache/ftccmap.c: Changed an FT_ERROR into an FT_TRACE1 since
-	it caused "ftview" and others to dump too much junk when trying to
-	display a waterfall with a font without a Unicode charmap (e.g. 
-	SYMBOL.TTF).
+	* src/cache/ftccmap.c (ftc_cmap_family_init): Changed an FT_ERROR
+	into an FT_TRACE1 since it caused "ftview" and others to dump too
+	much junk when trying to display a waterfall with a font without a
+	Unicode charmap (e.g.  SYMBOL.TTF).
 
 	Implemented FT_CONFIG_CHESTER_BLUE_SCALE, corresponding to the last
 	patch from David Chester, but with a much simpler (and saner)
@@ -423,7 +433,7 @@
 	invalid values for large negative angle differences (resulting in
 	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.
 
 	* src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: Adding
diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c
index a12fedc..2ba9b03 100644
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    The FreeType internal cache interface (body).                        */
 /*                                                                         */
-/*  Copyright 2000-2001, 2002 by                                           */
+/*  Copyright 2000-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -196,7 +196,7 @@
       FTC_Node*  pold;
 
 
-      if ( old_index+1 <= FTC_HASH_INITIAL_SIZE )
+      if ( old_index + 1 <= FTC_HASH_INITIAL_SIZE )
         goto Exit;
 
       if ( p == 0 )
@@ -567,24 +567,24 @@
 
     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 an OOM is detected, we'll try to free one or more "old" nodes
-    *  from the cache, then try again. it may be necessary to do that several
-    *  times, so a loop is needed.
+    *  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 times, so a loop is needed.
     *
-    *  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.
-    *  the loop stops when:
+    *  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.  The loop stops when:
     *
     *   - a non-OOM error is detected
     *   - a succesful lookup is performed
     *   - 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.
     */
 
@@ -747,13 +747,14 @@
       if ( error != FT_Err_Out_Of_Memory )
         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.
       */
       {
-        FT_UInt   new_count;
+        FT_UInt  new_count;
 
-        new_count = 1 + free_count*2;
+
+        new_count = 1 + free_count * 2;
 
         /* check overflow and bounds */
         if ( new_count < free_count || free_count > manager->num_nodes )
@@ -763,22 +764,24 @@
 
         /* try to remove "new_count" nodes from the list */
         {
-          FTC_Node   first = manager->nodes_list;
-          FTC_Node   node;
+          FTC_Node  first = manager->nodes_list;
+          FTC_Node  node;
+
 
-          if ( first == NULL )  /* empty list ! */
+          if ( first == NULL )  /* empty list! */
             goto Exit;
 
-         /* go to last node - it's a circular list */
+          /* go to last node - it's a circular list */
           node = first->mru_prev;
           for ( ; node && new_count > 0; new_count-- )
           {
             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
-            * our iteration
-            */
+
+            /* Used nodes always appear before unused one in the MRU
+             * list.  If we find one here, we'd better stop right now
+             * our iteration.
+             */
             if ( node->ref_count > 0 )
             {
               /* if there are no unused nodes in the list, we'd better exit */