Commit d3411f89 authored by Paul Eggert's avatar Paul Eggert

Use ptrdiff_t for hash table indexes.

* category.c (hash_get_category_set):
* ccl.c (ccl_driver):
* charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID):
* coding.c (coding_system_charset_list, detect_coding_system):
* coding.h (struct coding_system.id):
* composite.c (get_composition_id, gstring_lookup_cache):
* fns.c (hash_lookup, hash_put, Fgethash, Fputhash):
* image.c (xpm_get_color_table_h):
* lisp.h (hash_lookup, hash_put):
* minibuf.c (Ftest_completion):
Use ptrdiff_t for hash table indexes, not int (which is too
narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on
32-bit --with-wide-int hosts).
parent e097a6fa
2011-07-19 Paul Eggert <eggert@cs.ucla.edu>
Use ptrdiff_t for hash table indexes.
* category.c (hash_get_category_set):
* ccl.c (ccl_driver):
* charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID):
* coding.c (coding_system_charset_list, detect_coding_system):
* coding.h (struct coding_system.id):
* composite.c (get_composition_id, gstring_lookup_cache):
* fns.c (hash_lookup, hash_put, Fgethash, Fputhash):
* image.c (xpm_get_color_table_h):
* lisp.h (hash_lookup, hash_put):
* minibuf.c (Ftest_completion):
Use ptrdiff_t for hash table indexes, not int (which is too
narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on
32-bit --with-wide-int hosts).
* charset.c (Fdefine_charset_internal): Check for integer overflow.
Add a FIXME comment about memory leaks.
(syms_of_charset): Don't assume xmalloc returns.
......
......@@ -67,7 +67,7 @@ static Lisp_Object
hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
{
struct Lisp_Hash_Table *h;
EMACS_INT i;
ptrdiff_t i;
EMACS_UINT hash;
if (NILP (XCHAR_TABLE (table)->extras[1]))
......
......@@ -1303,7 +1303,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
case CCL_LookupIntConstTbl:
{
EMACS_INT eop;
ptrdiff_t eop;
struct Lisp_Hash_Table *h;
GET_CCL_RANGE (eop, ccl_prog, ic++, 0,
(VECTORP (Vtranslation_hash_table_vector)
......@@ -1329,7 +1329,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
case CCL_LookupCharConstTbl:
{
EMACS_INT eop;
ptrdiff_t eop;
struct Lisp_Hash_Table *h;
GET_CCL_RANGE (eop, ccl_prog, ic++, 0,
(VECTORP (Vtranslation_hash_table_vector)
......
......@@ -148,7 +148,7 @@ struct charset
int id;
/* Index to Vcharset_hash_table. */
EMACS_INT hash_index;
ptrdiff_t hash_index;
/* Dimension of the charset: 1, 2, 3, or 4. */
int dimension;
......@@ -341,7 +341,7 @@ extern int emacs_mule_charset[256];
number of the charset. Otherwise, signal an error. */
#define CHECK_CHARSET_GET_ID(x, id) \
do { \
int idx; \
ptrdiff_t idx; \
\
if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0) \
wrong_type_argument (Qcharsetp, (x)); \
......
......@@ -5838,7 +5838,7 @@ coding_charset_list (struct coding_system *coding)
Lisp_Object
coding_system_charset_list (Lisp_Object coding_system)
{
int id;
ptrdiff_t id;
Lisp_Object attrs, charset_list;
CHECK_CODING_SYSTEM_GET_ID (coding_system, id);
......@@ -8076,7 +8076,7 @@ detect_coding_system (const unsigned char *src,
Lisp_Object attrs, eol_type;
Lisp_Object val = Qnil;
struct coding_system coding;
int id;
ptrdiff_t id;
struct coding_detection_info detect_info;
enum coding_category base_category;
int null_byte_found = 0, eight_bit_found = 0;
......
......@@ -415,7 +415,7 @@ struct coding_system
setup_coding_system. At the early stage of building time, this
value is -1 in the array coding_categories to indicate that no
coding-system of that category is yet defined. */
int id;
ptrdiff_t id;
/* Flag bits of the coding system. The meaning of each bit is common
to all types of coding systems. */
......
......@@ -179,7 +179,7 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
Lisp_Object id, length, components, key, *key_contents;
int glyph_len;
struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table);
EMACS_INT hash_index;
ptrdiff_t hash_index;
EMACS_UINT hash_code;
struct composition *cmp;
EMACS_INT i;
......@@ -656,7 +656,7 @@ static Lisp_Object
gstring_lookup_cache (Lisp_Object header)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
EMACS_INT i = hash_lookup (h, header, NULL);
ptrdiff_t i = hash_lookup (h, header, NULL);
return (i >= 0 ? HASH_VALUE (h, i) : Qnil);
}
......
......@@ -3787,11 +3787,11 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
the hash code of KEY. Value is the index of the entry in H
matching KEY, or -1 if not found. */
EMACS_INT
ptrdiff_t
hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
{
EMACS_UINT hash_code;
EMACS_INT start_of_bucket;
ptrdiff_t start_of_bucket;
Lisp_Object idx;
hash_code = h->hashfn (h, key);
......@@ -3821,11 +3821,11 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
HASH is a previously computed hash code of KEY.
Value is the index of the entry in H matching KEY. */
EMACS_INT
ptrdiff_t
hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
EMACS_UINT hash)
{
EMACS_INT start_of_bucket, i;
ptrdiff_t start_of_bucket, i;
xassert ((hash & ~INTMASK) == 0);
......@@ -4482,7 +4482,7 @@ If KEY is not found, return DFLT which defaults to nil. */)
(Lisp_Object key, Lisp_Object table, Lisp_Object dflt)
{
struct Lisp_Hash_Table *h = check_hash_table (table);
EMACS_INT i = hash_lookup (h, key, NULL);
ptrdiff_t i = hash_lookup (h, key, NULL);
return i >= 0 ? HASH_VALUE (h, i) : dflt;
}
......@@ -4494,7 +4494,7 @@ VALUE. In any case, return VALUE. */)
(Lisp_Object key, Lisp_Object value, Lisp_Object table)
{
struct Lisp_Hash_Table *h = check_hash_table (table);
EMACS_INT i;
ptrdiff_t i;
EMACS_UINT hash;
i = hash_lookup (h, key, &hash);
......
......@@ -3807,8 +3807,8 @@ xpm_get_color_table_h (Lisp_Object color_table,
int chars_len)
{
struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
NULL);
ptrdiff_t i =
hash_lookup (table, make_unibyte_string (chars_start, chars_len), NULL);
return i >= 0 ? HASH_VALUE (table, i) : Qnil;
}
......
......@@ -2562,8 +2562,8 @@ EMACS_UINT sxhash (Lisp_Object, int);
Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object);
EMACS_INT hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
EMACS_INT hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
EMACS_UINT);
void init_weak_hash_tables (void);
extern void init_fns (void);
......
......@@ -1713,7 +1713,7 @@ the values STRING, PREDICATE and `lambda'. */)
(Lisp_Object string, Lisp_Object collection, Lisp_Object predicate)
{
Lisp_Object regexps, tail, tem = Qnil;
EMACS_INT i = 0;
ptrdiff_t i = 0;
CHECK_STRING (string);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment