... |
... |
@@ -426,7 +426,7 @@ |
426
|
426
|
memory = manager->memory;
|
427
|
427
|
|
428
|
428
|
/* now discard all caches */
|
429
|
|
- for (idx = manager->num_caches; idx-- > 0; )
|
|
429
|
+ for ( idx = manager->num_caches; idx-- > 0; )
|
430
|
430
|
{
|
431
|
431
|
FTC_Cache cache = manager->caches[idx];
|
432
|
432
|
|
... |
... |
@@ -537,7 +537,7 @@ |
537
|
537
|
FT_LOCAL_DEF( void )
|
538
|
538
|
FTC_Manager_Compress( FTC_Manager manager )
|
539
|
539
|
{
|
540
|
|
- FTC_Node node, first;
|
|
540
|
+ FTC_Node node, prev, first;
|
541
|
541
|
|
542
|
542
|
|
543
|
543
|
if ( !manager )
|
... |
... |
@@ -557,20 +557,16 @@ |
557
|
557
|
return;
|
558
|
558
|
|
559
|
559
|
/* go to last node -- it's a circular list */
|
560
|
|
- node = FTC_NODE_PREV( first );
|
|
560
|
+ prev = FTC_NODE_PREV( first );
|
561
|
561
|
do
|
562
|
562
|
{
|
563
|
|
- FTC_Node prev;
|
564
|
|
-
|
565
|
|
-
|
566
|
|
- prev = ( node == first ) ? NULL : FTC_NODE_PREV( node );
|
|
563
|
+ node = prev;
|
|
564
|
+ prev = FTC_NODE_PREV( node );
|
567
|
565
|
|
568
|
566
|
if ( node->ref_count <= 0 )
|
569
|
567
|
ftc_node_destroy( node, manager );
|
570
|
568
|
|
571
|
|
- node = prev;
|
572
|
|
-
|
573
|
|
- } while ( node && manager->cur_weight > manager->max_weight );
|
|
569
|
+ } while ( node != first && manager->cur_weight > manager->max_weight );
|
574
|
570
|
}
|
575
|
571
|
|
576
|
572
|
|
... |
... |
@@ -633,20 +629,20 @@ |
633
|
629
|
FT_UInt count )
|
634
|
630
|
{
|
635
|
631
|
FTC_Node first = manager->nodes_list;
|
636
|
|
- FTC_Node node;
|
637
|
|
- FT_UInt result;
|
|
632
|
+ FTC_Node prev, node;
|
|
633
|
+ FT_UInt result = 0;
|
638
|
634
|
|
639
|
635
|
|
640
|
636
|
/* try to remove `count' nodes from the list */
|
641
|
|
- if ( !first ) /* empty list! */
|
642
|
|
- return 0;
|
|
637
|
+ if ( !first || !count )
|
|
638
|
+ return result;
|
643
|
639
|
|
644
|
|
- /* go to last node - it's a circular list */
|
645
|
|
- node = FTC_NODE_PREV(first);
|
646
|
|
- for ( result = 0; result < count; )
|
|
640
|
+ /* go to last node -- it's a circular list */
|
|
641
|
+ prev = FTC_NODE_PREV( first );
|
|
642
|
+ do
|
647
|
643
|
{
|
648
|
|
- FTC_Node prev = FTC_NODE_PREV( node );
|
649
|
|
-
|
|
644
|
+ node = prev;
|
|
645
|
+ prev = FTC_NODE_PREV( node );
|
650
|
646
|
|
651
|
647
|
/* don't touch locked nodes */
|
652
|
648
|
if ( node->ref_count <= 0 )
|
... |
... |
@@ -654,13 +650,9 @@ |
654
|
650
|
ftc_node_destroy( node, manager );
|
655
|
651
|
result++;
|
656
|
652
|
}
|
|
653
|
+ } while ( node != first && result < count );
|
657
|
654
|
|
658
|
|
- if ( node == first )
|
659
|
|
- break;
|
660
|
|
-
|
661
|
|
- node = prev;
|
662
|
|
- }
|
663
|
|
- return result;
|
|
655
|
+ return result;
|
664
|
656
|
}
|
665
|
657
|
|
666
|
658
|
|