Commit 98d2701c58f805861e22a0a3c03e7ad984abb96e

David Turner 2000-08-24T11:53:35

changed the FTC_Manager_New function to accept "max_faces" and "max_sizes" parameters fixed some bugs. the cache manager is now tested and validated (now, it's time for the glyph image cache)

diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index 37ec8ad..7be5199 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -154,6 +154,12 @@
   *  <Input>
   *     library   :: the parent FreeType library handle to use
   *
+  *     max_faces :: maximum number of faces to keep alive in manager
+  *                  use 0 for defaults
+  *
+  *     max_sizes :: maximum number of sizes to keep alive in manager
+  *                  use 0 for defaults
+  *
   *     requester :: an application-provided callback used to translate
   *                  face IDs into real FT_Face objects
   *
@@ -169,6 +175,8 @@
   **************************************************************************/
   
   FT_EXPORT_DEF( FT_Error )  FTC_Manager_New( FT_Library          library,
+                                              FT_UInt             max_faces,
+					      FT_UInt             max_sizes,
                                               FTC_Face_Requester  requester,
                                               FT_Pointer          req_data,
                                               FTC_Manager*        amanager );
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 3a9a0d3..d0c4399 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -104,15 +104,17 @@
     FTC_SizeRequest*  size_req = (FTC_SizeRequest*)node->key;
     FT_Size           size;
     FT_Error          error;
+    FT_Face           face = size_req->face;
     
     FT_UNUSED( lru );
 
     
     node->root.data = 0;
-    error = FT_New_Size( size_req->face, &size );
+    error = FT_New_Size( face, &size );
     if ( !error )
     {
-      error = FT_Set_Pixel_Sizes( size_req->face,
+      face->size = size;
+      error = FT_Set_Pixel_Sizes( face,
                                   size_req->width,
                                   size_req->height );
       if ( error )
@@ -200,6 +202,8 @@
 
 
   FT_EXPORT_FUNC( FT_Error )  FTC_Manager_New( FT_Library          library,
+                                               FT_UInt             max_faces,
+					       FT_UInt             max_sizes,
                                                FTC_Face_Requester  requester,
                                                FT_Pointer          req_data,
                                                FTC_Manager*        amanager )
@@ -211,9 +215,15 @@
     
     if ( ALLOC( manager, sizeof ( *manager ) ) )
       goto Exit;
+    
+    if (max_faces == 0)
+      max_faces = FTC_MAX_FACES;
+      
+    if (max_sizes == 0)
+      max_sizes = FTC_MAX_SIZES;
       
     error = FT_Lru_New( &ftc_face_lru_class,
-                        FTC_MAX_FACES,
+                        max_faces,
                         manager,
                         memory,
                         1, /* pre_alloc = TRUE */
@@ -222,7 +232,7 @@
       goto Exit;
       
     error = FT_Lru_New( &ftc_size_lru_class,
-                        FTC_MAX_SIZES,
+                        max_sizes,
                         manager,
                         memory,
                         1, /* pre_alloc = TRUE */
diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c
index e4e60a9..1c1cc61 100644
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -159,6 +159,7 @@
         
         node     = lru->elements.tail;
         lru_node = (FT_LruNode)node;
+        found    = lru_node;
         
         if ( clazz->flush_element )
           error = clazz->flush_element( lru, lru_node, key );
@@ -185,6 +186,8 @@
             FT_List_Insert( &lru->free_nodes, node );
           else
             FREE( lru_node );
+            
+          found = 0;
         }
       }
       else