Commit 3aaebe3a91e55021d99b06f95594c5ff9181968a

Werner Lemberg 2015-02-23T08:20:27

[cache] Replace `FT_PtrDist' with `FT_Offset'. * 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.

diff --git a/ChangeLog b/ChangeLog
index 9444595..dc09a0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2015-02-23  Werner Lemberg  <wl@gnu.org>
 
+	[cache] Replace `FT_PtrDist' with `FT_Offset'.
+
+	* 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.
+
+2015-02-23  Werner Lemberg  <wl@gnu.org>
+
 	[smooth, raster] Re-enable standalone compilation.
 
 	* src/raster/ftraster.c (FT_RENDER_POOL_SIZE, FT_MAX)
@@ -306,7 +320,7 @@
 	type to `FT_Long'.
 	(CONST_FT_RFORK_RULE_ARRAY_BEGIN): Add `static' keyword.
 
-	* include/internal/ftstream.h (FT_Stream_Pos): Return `FT_ULong'. 
+	* include/internal/ftstream.h (FT_Stream_Pos): Return `FT_ULong'.
 
 	* src/base/ftoutln.c, src/base/ftrfork.c, src/base/ftstream.c:
 	Signedess fixes.
diff --git a/src/cache/ftcbasic.c b/src/cache/ftcbasic.c
index 2233821..dbee89a 100644
--- a/src/cache/ftcbasic.c
+++ b/src/cache/ftcbasic.c
@@ -45,8 +45,8 @@
           FT_BOOL( FTC_SCALER_COMPARE( &(a)->scaler, &(b)->scaler ) && \
                    (a)->load_flags == (b)->load_flags               )
 
-#define FTC_BASIC_ATTR_HASH( a )                                   \
-          ( FTC_SCALER_HASH( &(a)->scaler ) + 31*(a)->load_flags )
+#define FTC_BASIC_ATTR_HASH( a )                                     \
+          ( FTC_SCALER_HASH( &(a)->scaler ) + 31 * (a)->load_flags )
 
 
   typedef struct  FTC_BasicQueryRec_
@@ -283,7 +283,7 @@
     FTC_BasicQueryRec  query;
     FTC_Node           node = 0; /* make compiler happy */
     FT_Error           error;
-    FT_PtrDist         hash;
+    FT_Offset          hash;
 
 
     /* some argument checks are delayed to `FTC_Cache_Lookup' */
@@ -356,7 +356,7 @@
     FTC_BasicQueryRec  query;
     FTC_Node           node = 0; /* make compiler happy */
     FT_Error           error;
-    FT_PtrDist         hash;
+    FT_Offset          hash;
 
 
     /* some argument checks are delayed to `FTC_Cache_Lookup' */
@@ -466,7 +466,7 @@
     FT_Error           error;
     FTC_BasicQueryRec  query;
     FTC_Node           node = 0; /* make compiler happy */
-    FT_PtrDist         hash;
+    FT_Offset          hash;
 
 
     if ( anode )
@@ -541,7 +541,7 @@
     FT_Error           error;
     FTC_BasicQueryRec  query;
     FTC_Node           node = 0; /* make compiler happy */
-    FT_PtrDist         hash;
+    FT_Offset          hash;
 
 
     if ( anode )
diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c
index e1d52fa..d8c5b99 100644
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -88,16 +88,16 @@
    * body for FTC_NODE__TOP_FOR_HASH( cache, hash )
    */
   FT_LOCAL_DEF( FTC_Node* )
-  ftc_get_top_node_for_hash( FTC_Cache   cache,
-                             FT_PtrDist  hash )
+  ftc_get_top_node_for_hash( FTC_Cache  cache,
+                             FT_Offset  hash )
   {
     FTC_Node*  pnode;
-    FT_UInt    idx;
+    FT_Offset  idx;
 
 
-    idx = (FT_UInt)( hash & cache->mask );
+    idx = hash & cache->mask;
     if ( idx < cache->p )
-      idx = (FT_UInt)( hash & ( 2 * cache->mask + 1 ) );
+      idx = hash & ( 2 * cache->mask + 1 );
     pnode = cache->buckets + idx;
     return pnode;
   }
@@ -414,7 +414,7 @@
 
   static void
   ftc_cache_add( FTC_Cache  cache,
-                 FT_PtrDist hash,
+                 FT_Offset  hash,
                  FTC_Node   node )
   {
     node->hash        = hash;
@@ -442,7 +442,7 @@
 
   FT_LOCAL_DEF( FT_Error )
   FTC_Cache_NewNode( FTC_Cache   cache,
-                     FT_PtrDist  hash,
+                     FT_Offset   hash,
                      FT_Pointer  query,
                      FTC_Node   *anode )
   {
@@ -481,7 +481,7 @@
 
   FT_LOCAL_DEF( FT_Error )
   FTC_Cache_Lookup( FTC_Cache   cache,
-                    FT_PtrDist  hash,
+                    FT_Offset   hash,
                     FT_Pointer  query,
                     FTC_Node   *anode )
   {
diff --git a/src/cache/ftccache.h b/src/cache/ftccache.h
index ba1dfee..4e17c7a 100644
--- a/src/cache/ftccache.h
+++ b/src/cache/ftccache.h
@@ -24,8 +24,8 @@
 
 FT_BEGIN_HEADER
 
-#define _FTC_FACE_ID_HASH( i )                                                \
-          ((FT_PtrDist)(( (FT_PtrDist)(i) >> 3 ) ^ ( (FT_PtrDist)(i) << 7 )))
+#define _FTC_FACE_ID_HASH( i )                                  \
+          ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
 
   /* handle to cache object */
   typedef struct FTC_CacheRec_*  FTC_Cache;
@@ -59,7 +59,7 @@ FT_BEGIN_HEADER
   {
     FTC_MruNodeRec  mru;          /* circular mru list pointer           */
     FTC_Node        link;         /* used for hashing                    */
-    FT_PtrDist      hash;         /* used for hashing too                */
+    FT_Offset       hash;         /* used for hashing too                */
     FT_UShort       cache_index;  /* index of cache the node belongs to  */
     FT_Short        ref_count;    /* reference count for this node       */
 
@@ -80,8 +80,8 @@ FT_BEGIN_HEADER
               : ( ( hash ) &   ( cache )->mask ) ) )
 #else
   FT_LOCAL( FTC_Node* )
-  ftc_get_top_node_for_hash( FTC_Cache   cache,
-                             FT_PtrDist  hash );
+  ftc_get_top_node_for_hash( FTC_Cache  cache,
+                             FT_Offset  hash );
 #define FTC_NODE__TOP_FOR_HASH( cache, hash )            \
         ftc_get_top_node_for_hash( ( cache ), ( hash ) )
 #endif
@@ -179,14 +179,14 @@ FT_BEGIN_HEADER
 #ifndef FTC_INLINE
   FT_LOCAL( FT_Error )
   FTC_Cache_Lookup( FTC_Cache   cache,
-                    FT_PtrDist  hash,
+                    FT_Offset   hash,
                     FT_Pointer  query,
                     FTC_Node   *anode );
 #endif
 
   FT_LOCAL( FT_Error )
   FTC_Cache_NewNode( FTC_Cache   cache,
-                     FT_PtrDist  hash,
+                     FT_Offset   hash,
                      FT_Pointer  query,
                      FTC_Node   *anode );
 
@@ -211,7 +211,7 @@ FT_BEGIN_HEADER
   FT_BEGIN_STMNT                                                         \
     FTC_Node             *_bucket, *_pnode, _node;                       \
     FTC_Cache             _cache   = FTC_CACHE(cache);                   \
-    FT_PtrDist            _hash    = (FT_PtrDist)(hash);                 \
+    FT_Offset             _hash    = (FT_Offset)(hash);                  \
     FTC_Node_CompareFunc  _nodcomp = (FTC_Node_CompareFunc)(nodecmp);    \
     FT_Bool               _list_changed = FALSE;                         \
                                                                          \
diff --git a/src/cache/ftccmap.c b/src/cache/ftccmap.c
index 0ef4423..a127435 100644
--- a/src/cache/ftccmap.c
+++ b/src/cache/ftccmap.c
@@ -242,7 +242,7 @@
     FTC_Node          node;
     FT_Error          error;
     FT_UInt           gindex = 0;
-    FT_PtrDist        hash;
+    FT_Offset         hash;
     FT_Int            no_cmap_change = 0;
 
 
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index edb745f..343b8a7 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -185,7 +185,7 @@
 
   FT_LOCAL_DEF( FT_Error )
   FTC_GCache_Lookup( FTC_GCache   cache,
-                     FT_PtrDist   hash,
+                     FT_Offset    hash,
                      FT_UInt      gindex,
                      FTC_GQuery   query,
                      FTC_Node    *anode )
diff --git a/src/cache/ftcglyph.h b/src/cache/ftcglyph.h
index af4d0ce..6cadbe2 100644
--- a/src/cache/ftcglyph.h
+++ b/src/cache/ftcglyph.h
@@ -260,7 +260,7 @@ FT_BEGIN_HEADER
 #ifndef FTC_INLINE
   FT_LOCAL( FT_Error )
   FTC_GCache_Lookup( FTC_GCache   cache,
-                     FT_PtrDist   hash,
+                     FT_Offset    hash,
                      FT_UInt      gindex,
                      FTC_GQuery   query,
                      FTC_Node    *anode );