projects
/
platform
/
upstream
/
freetype2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 2.13.2
[platform/upstream/freetype2.git]
/
src
/
cache
/
ftcmanag.c
diff --git
a/src/cache/ftcmanag.c
b/src/cache/ftcmanag.c
index
436d41f
..
94f8469
100644
(file)
--- a/
src/cache/ftcmanag.c
+++ b/
src/cache/ftcmanag.c
@@
-4,7
+4,7
@@
*
* FreeType Cache Manager (body).
*
*
* FreeType Cache Manager (body).
*
- * Copyright (C) 2000-202
0
by
+ * Copyright (C) 2000-202
3
by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@@
-357,7
+357,7
@@
{
FT_Error error;
FT_Memory memory;
{
FT_Error error;
FT_Memory memory;
- FTC_Manager manager =
0
;
+ FTC_Manager manager =
NULL
;
if ( !library )
if ( !library )
@@
-368,7
+368,7
@@
memory = library->memory;
memory = library->memory;
- if ( FT_NEW( manager ) )
+ if ( FT_
Q
NEW( manager ) )
goto Exit;
if ( max_faces == 0 )
goto Exit;
if ( max_faces == 0 )
@@
-383,6
+383,7
@@
manager->library = library;
manager->memory = memory;
manager->max_weight = max_bytes;
manager->library = library;
manager->memory = memory;
manager->max_weight = max_bytes;
+ manager->cur_weight = 0;
manager->request_face = requester;
manager->request_data = req_data;
manager->request_face = requester;
manager->request_data = req_data;
@@
-399,6
+400,10
@@
manager,
memory );
manager,
memory );
+ manager->nodes_list = NULL;
+ manager->num_nodes = 0;
+ manager->num_caches = 0;
+
*amanager = manager;
Exit:
*amanager = manager;
Exit:
@@
-421,7
+426,7
@@
memory = manager->memory;
/* now discard all caches */
memory = manager->memory;
/* now discard all caches */
- for (idx = manager->num_caches; idx-- > 0; )
+ for (
idx = manager->num_caches; idx-- > 0; )
{
FTC_Cache cache = manager->caches[idx];
{
FTC_Cache cache = manager->caches[idx];
@@
-484,8
+489,8
@@
FTC_Cache cache = manager->caches[node->cache_index];
FTC_Cache cache = manager->caches[node->cache_index];
- if (
(FT_UInt)
node->cache_index >= manager->num_caches )
- FT_TRACE0(( "FTC_Manager_Check: invalid node (cache index = %
ld
\n",
+ if ( node->cache_index >= manager->num_caches )
+ FT_TRACE0(( "FTC_Manager_Check: invalid node (cache index = %
hu
\n",
node->cache_index ));
else
weight += cache->clazz.node_weight( node, cache );
node->cache_index ));
else
weight += cache->clazz.node_weight( node, cache );
@@
-515,7
+520,7
@@
if ( count != manager->num_nodes )
FT_TRACE0(( "FTC_Manager_Check:"
if ( count != manager->num_nodes )
FT_TRACE0(( "FTC_Manager_Check:"
- " invalid cache node count %
d instead of %d
\n",
+ " invalid cache node count %
u instead of %u
\n",
manager->num_nodes, count ));
}
}
manager->num_nodes, count ));
}
}
@@
-532,7
+537,7
@@
FT_LOCAL_DEF( void )
FTC_Manager_Compress( FTC_Manager manager )
{
FT_LOCAL_DEF( void )
FTC_Manager_Compress( FTC_Manager manager )
{
- FTC_Node node, first;
+ FTC_Node node,
prev,
first;
if ( !manager )
if ( !manager )
@@
-543,7
+548,7
@@
#ifdef FT_DEBUG_ERROR
FTC_Manager_Check( manager );
#ifdef FT_DEBUG_ERROR
FTC_Manager_Check( manager );
- FT_TRACE0(( "compressing, weight = %ld, max = %ld, nodes = %
d
\n",
+ FT_TRACE0(( "compressing, weight = %ld, max = %ld, nodes = %
u
\n",
manager->cur_weight, manager->max_weight,
manager->num_nodes ));
#endif
manager->cur_weight, manager->max_weight,
manager->num_nodes ));
#endif
@@
-552,20
+557,16
@@
return;
/* go to last node -- it's a circular list */
return;
/* go to last node -- it's a circular list */
-
node
= FTC_NODE_PREV( first );
+
prev
= FTC_NODE_PREV( first );
do
{
do
{
- FTC_Node prev;
-
-
- prev = ( node == first ) ? NULL : FTC_NODE_PREV( node );
+ node = prev;
+ prev = FTC_NODE_PREV( node );
if ( node->ref_count <= 0 )
ftc_node_destroy( node, manager );
if ( node->ref_count <= 0 )
ftc_node_destroy( node, manager );
- node = prev;
-
- } while ( node && manager->cur_weight > manager->max_weight );
+ } while ( node != first && manager->cur_weight > manager->max_weight );
}
}
@@
-593,7
+594,7
@@
goto Exit;
}
goto Exit;
}
- if ( !FT_ALLOC( cache, clazz->cache_size ) )
+ if ( !FT_
Q
ALLOC( cache, clazz->cache_size ) )
{
cache->manager = manager;
cache->memory = memory;
{
cache->manager = manager;
cache->memory = memory;
@@
-628,20
+629,20
@@
FT_UInt count )
{
FTC_Node first = manager->nodes_list;
FT_UInt count )
{
FTC_Node first = manager->nodes_list;
- FTC_Node node;
- FT_UInt result;
+ FTC_Node
prev,
node;
+ FT_UInt result
= 0
;
/* try to remove `count' nodes from the list */
/* try to remove `count' nodes from the list */
- if ( !first
) /* empty list! */
- return
0
;
+ if ( !first
|| !count )
+ return
result
;
- /* go to last node - it's a circular list */
-
node = FTC_NODE_PREV(first
);
- for ( result = 0; result < count; )
+ /* go to last node -
-
it's a circular list */
+
prev = FTC_NODE_PREV( first
);
+ do
{
{
-
FTC_Node prev = FTC_NODE_PREV( node )
;
-
+
node = prev
;
+ prev = FTC_NODE_PREV( node );
/* don't touch locked nodes */
if ( node->ref_count <= 0 )
/* don't touch locked nodes */
if ( node->ref_count <= 0 )
@@
-649,13
+650,9
@@
ftc_node_destroy( node, manager );
result++;
}
ftc_node_destroy( node, manager );
result++;
}
+ } while ( node != first && result < count );
- if ( node == first )
- break;
-
- node = prev;
- }
- return result;
+ return result;
}
}
@@
-689,9
+686,9
@@
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager )
{
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager )
{
- if ( node
&&
- manager
&&
-
(FT_UInt)
node->cache_index < manager->num_caches )
+ if ( node &&
+ manager &&
+ node->cache_index < manager->num_caches )
node->ref_count--;
}
node->ref_count--;
}