[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] FT_LruList_Remove_Selection doesn't update list->num_nodes
From: |
Alexander Malmberg |
Subject: |
[Devel] FT_LruList_Remove_Selection doesn't update list->num_nodes |
Date: |
Sat, 07 Jun 2003 21:24:16 +0200 |
Hi
In 2.1.4, FT_LruList_Remove_Selection doesn't update list->num_nodes
when it removes nodes. In some cases, this causes the cache system to
start returning spurious out of memory errors. I have no simple test
that shows the errors, but this assertion at the end of the function:
{
FT_LruNode node;
int num=0;
for (node=list->nodes;node;node=node->next)
num++;
FT_ASSERT(num==list->num_nodes);
}
will trigger if you run ftview with three fonts and switch back and
forth between them. I've attached a patch that fixes this and corrects a
related assertion in FT_LruList_Lookup.
While debugging this, I found ftccache.c:759, the "if (... || free_count
> manager->num_nodes)", somewhat questionable. Even if it isn't possible to
> free as many nodes as we want to, it seems more sensible to free as many as
> possible and try again before failing (or I am reading the code wrong?).
- Alexander Malmberg (not on the list, please cc replies)
Index: ftlru.c
===================================================================
RCS file: /cvs/freetype/freetype2/src/cache/ftlru.c,v
retrieving revision 1.27
diff -u -r1.27 ftlru.c
--- ftlru.c 2003/03/20 07:04:40 1.27
+++ ftlru.c 2003/06/07 19:01:36
@@ -231,7 +231,7 @@
if ( node == NULL )
{
- FT_ASSERT( list->nodes == 0 );
+ FT_ASSERT( list->num_nodes == 0 );
error = FT_Err_Out_Of_Memory;
goto Exit;
}
@@ -384,6 +384,7 @@
clazz->node_done( node, list );
FT_FREE( node );
+ list->num_nodes--;
}
else
pnode = &(*pnode)->next;
- [Devel] FT_LruList_Remove_Selection doesn't update list->num_nodes,
Alexander Malmberg <=