This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.
No change in functionality, of course.
I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
Such macro names are reserved for both C and C++.
* src/cache/ftccache.h: s/_FTC_FACE_ID_HASH/FTC_FACE_ID_HASH/.
Update all callers.
(FTC_CACHE_LOOKUP_CMP): Replace `_XXX' with `XXX_'.
* src/cache/ftcmru.c (FTC_MRULIST_LOOKUP_CMP): Ditto.
* src/cache/ftccache.h (FTC_NodeRec): `FT_Offset' (a.k.a. `size_t')
is a better choice for `hash' to hold a pointer than `FT_PtrDist'
(a.k.a. `ptrdiff_t'), especially since the latter is signed,
causing zillions of signedness warnings. [Note that `hash' was of
type `FT_UInt32' before the change to `FT_PtrDist.]
Update all users.
* src/cache/ftcbasic.c, src/cache/ftccache.c, src/cache/ftccmap.c,
src/cache/ftcglyph.c, src/cache/ftcglyph.h: Updated.
When a node comparator changes the cached nodes during the
search of a node matching with queried properties, the
pointers obtained before the functon should be updated to
prevent the dereference to freed or reallocated nodes.
To minimize the rescan of the linked list, the update is
executed when the comparator notifies the change of cached
nodes. This change depends previous change:
38b272ffbb
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Rescan the
top node if the cached nodes are changed.
* src/cache/ftccache.c (FTC_Cache_Lookup): Ditto.
Some node comparators (comparing the cache node content and
the properties specified by the query) can flush the cache
node to prevent the cache inflation. The change may
invalidate the pointers to the node obtained before the node
comparison, so the change should be noticed to the caller.
The problem caused by the cache node changing is reported by
Harsha, see Savannah bug #31923.
* src/cache/ftccache.h (FTC_Node_CompareFunc): Add new
argument `FT_Bool* list_changed' to indicate the change of
the cached nodes to the caller.
(FTC_CACHE_LOOKUP_CMP): Watch the change of the cached nodes
by `_list_changed'.
(FTC_CACHE_TRYLOOP_END): Take new macro argument `_list_changed'
and update it when FTC_Manager_FlushN() flushes any nodes.
* src/cache/ftccback.h (ftc_snode_compare): Updated to fit
with new FTC_Node_CompareFunc type. (ftc_gnode_compare): Ditto.
* src/cache/ftcbasic.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros. (ftc_basic_gnode_compare_faceid):
New argument `FT_Bool* list_changed' to indicate the change
of the cache nodes, anyway, it is always FALSE.
* src/cache/ftccmap.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros. (ftc_cmap_node_compare):
New argument `FT_Bool* list_changed' to indicate the change
of the cache nodes, anyway, it is always FALSE.
(ftc_cmap_node_remove_faceid): Ditto.
* src/cache/ftccache.c (FTC_Cache_NewNode): Pass a NULL
pointer to FTC_CACHE_TRYLOOP_END(), because the result is
not needed. (FTC_Cache_Lookup): Watch the change of the cache
nodes by `list_changed'. (FTC_Cache_RemoveFaceID): Ditto.
* src/cache/ftcglyph.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros. (ftc_gnode_compare): New argument
`FT_Bool* list_changed' to indicate the change of the cache
nodes, anyway, it is always FALSE. (FTC_GNode_Compare):
New argument `FT_Bool* list_changed' to be passed to
ftc_gnode_compare().
* src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto.
* src/cache/ftcsbits.c (ftc_snode_compare): New argument
`FT_Bool* list_changed' to indicate the change of the cache
nodes, anyway. It is updated by FTC_CACHE_TRYLOOP().
(FTC_SNode_Compare): New argument `FT_Bool* list_changed'
to be passed to ftc_snode_compare().
* src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
There are several duplicated codes getting the top node
from a cache by a given hash, like:
idx = hash & cache->mask;
if ( idx < cache->p )
idx = hash & ( cache->mask * 2 + 1 );
pnode = cache->buckets + idx;
To deduplicate them, a cpp-macro to do same work
FTC_NODE__TOP_FOR_HASH( cache, hash ) is introduced.
For non-inlined config, non-ftc_get_top_node_for_hash() is
also introduced.
* src/cache/ftccache.h (FTC_NODE__TOP_FOR_HASH): Declare
and implement inlined version.
(FTC_CACHE_LOOKUP_CMP): Use FTC_NODE__TOP_FOR_HASH().
* src/cache/ftccache.c (ftc_get_top_node_for_hash): Non-
inlined version.
(ftc_node_hash_unlink): Use FTC_NODE__TOP_FOR_HASH().
(ftc_node_hash_link): Ditto.
(FTC_Cache_Lookup): Ditto.
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Revert
the type of `_idx' from FT_PtrDist (by previous change)
to original FT_UFast, to match with FT_CacheRec.
On LLP64 platforms (e.g. Win64), FT_ULong (32-bit)
variables are inappropriate to calculate hash values
from the memory address (64-bit). The hash variables
are extended from FT_ULong to FT_PtrDist and new
hashing macro functions are introduced. The hash
values on 16-bit memory platforms are changed, but
ILP32 and LP64 are not changed. The hash value in
the cache subsystem is not reverted to the memory
address, so using signed type FT_PtrDist is safe.
* src/cache/ftccache.h (_FTC_FACE_ID_HASH): New hash
function to replace FTC_FACE_ID_HASH() for portability.
* src/cache/ftcmanag.h (FTC_SCALER_HASH): Replace
FTC_FACE_ID_HASH() by _FTC_FACE_ID_HASH().
* src/cache/ftccmap.c (FTC_CMAP_HASH): Ditto.
* src/cache/ftccache.h (FTC_NodeRec): The type of the
member `hash' is changed from FT_UInt32 to FT_PtrDist.
* src/cache/ftccache.h (FTC_Cache_Lookup): The type of the
argument `hash' is changed from FT_UInt32 to FT_PtrDist.
(FTC_Cache_NewNode): Ditto.
* src/cache/ftccache.c (ftc_cache_add): Ditto.
(FTC_Cache_Lookup): Ditto. (FTC_Cache_NewNode): Ditto.
* src/cache/ftcglyph.h (FTC_GCache_Lookup): Ditto.
* src/cache/ftcglyph.c (FTC_GCache_Lookup): Ditto.
* src/cache/ftcbasic.c (FTC_ImageCache_Lookup): The type
of the internal variable `hash' is changed to FT_PtrDist
from FT_UInt32. (FTC_ImageCache_LookupScaler): Ditto.
(FTC_SBitCache_Lookup): Ditto.
(FTC_SBitCache_LookupScaler): Ditto.
* src/cache/ftccmap.c (FTC_CMapCache_Lookup): Ditto.
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Ditto.
Also the type of the internal variable `_idx' is changed to
FT_PtrDist from FT_UInt32 for better pointer calculation.
include/freetype/cache/ftccmap.h,
include/freetype/cache/ftcglyph.h
include/freetype/cache/ftcimage.h
include/freetype/cache/ftcmanag.h
include/freetype/cache/ftcmru.h
include/freetype/cache/ftcsbits.h:
removing these header files from the public include directory.
* include/freetype/config/ftheader.h:
changing the definition of FT_CACHE_INTERNAL_XXX_H macros to
redirect to FT_CACHE_H instead
* src/cache/ftcbasic.c, src/cache/ftccache.c, src/cache/ftccache.h,
src/cache/ftccback.h, src/cache/ftccmap.c, src/cache/ftcglyph.c,
src/cache/ftcglyph.h, src/cache/ftcimage.c, src/cache/ftcimage.h,
src/cache/ftcmanag.c, src/cache/ftcmanag.h, src/cache/ftcmru.c,
src/cache/ftcmru.h, src/cache/ftcsbits.c, src/cache/ftcsbits.h:
modifications to prevent using the FT_CACHE_INTERNAL_XXX_H macros,
and grab the headers in 'src/cache' instead (see below).
src/cache/ftcsbits.h, src/cache/ftcmanag.h, src/cache/ftccmap.h,
src/cache/ftcmru.h: copying the cache's internal header files which
were located in 'include/freetype/cache' to the 'src/cache' directory
instead.
Note that these files are not used by FreeType clients, all cache
public APIs have been already moved to include/freetype/ftcache.h,
and the FT_CACHE_INTERNAL_XXXX_H macros all resolve to it.
the move is to allow us to modify the internals without intereference
from rogue clients. Note that there are no known client that accesses
the cache internals at the moment.