aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-18 23:07:07 -0700
committerPaul Eggert2011-07-18 23:07:07 -0700
commitd3411f89d34bd1009cae738f917abf477be09882 (patch)
tree1faf0e2f21f2ea5e19a33eb5ae1c4ae633a1f1ea /src
parente097a6fa863b26952a476e71a786fa7b2460277b (diff)
downloademacs-d3411f89d34bd1009cae738f917abf477be09882.tar.gz
emacs-d3411f89d34bd1009cae738f917abf477be09882.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/category.c2
-rw-r--r--src/ccl.c4
-rw-r--r--src/charset.h4
-rw-r--r--src/coding.c4
-rw-r--r--src/coding.h2
-rw-r--r--src/composite.c4
-rw-r--r--src/fns.c12
-rw-r--r--src/image.c4
-rw-r--r--src/lisp.h4
-rw-r--r--src/minibuf.c2
11 files changed, 36 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4a9e03d5da0..cf75596f422 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,20 @@
12011-07-19 Paul Eggert <eggert@cs.ucla.edu> 12011-07-19 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Use ptrdiff_t for hash table indexes.
4 * category.c (hash_get_category_set):
5 * ccl.c (ccl_driver):
6 * charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID):
7 * coding.c (coding_system_charset_list, detect_coding_system):
8 * coding.h (struct coding_system.id):
9 * composite.c (get_composition_id, gstring_lookup_cache):
10 * fns.c (hash_lookup, hash_put, Fgethash, Fputhash):
11 * image.c (xpm_get_color_table_h):
12 * lisp.h (hash_lookup, hash_put):
13 * minibuf.c (Ftest_completion):
14 Use ptrdiff_t for hash table indexes, not int (which is too
15 narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on
16 32-bit --with-wide-int hosts).
17
3 * charset.c (Fdefine_charset_internal): Check for integer overflow. 18 * charset.c (Fdefine_charset_internal): Check for integer overflow.
4 Add a FIXME comment about memory leaks. 19 Add a FIXME comment about memory leaks.
5 (syms_of_charset): Don't assume xmalloc returns. 20 (syms_of_charset): Don't assume xmalloc returns.
diff --git a/src/category.c b/src/category.c
index 08eadb04730..a822bb654b0 100644
--- a/src/category.c
+++ b/src/category.c
@@ -67,7 +67,7 @@ static Lisp_Object
67hash_get_category_set (Lisp_Object table, Lisp_Object category_set) 67hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
68{ 68{
69 struct Lisp_Hash_Table *h; 69 struct Lisp_Hash_Table *h;
70 EMACS_INT i; 70 ptrdiff_t i;
71 EMACS_UINT hash; 71 EMACS_UINT hash;
72 72
73 if (NILP (XCHAR_TABLE (table)->extras[1])) 73 if (NILP (XCHAR_TABLE (table)->extras[1]))
diff --git a/src/ccl.c b/src/ccl.c
index 9cfcbfe8703..087c0feb4ab 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1303,7 +1303,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1303 1303
1304 case CCL_LookupIntConstTbl: 1304 case CCL_LookupIntConstTbl:
1305 { 1305 {
1306 EMACS_INT eop; 1306 ptrdiff_t eop;
1307 struct Lisp_Hash_Table *h; 1307 struct Lisp_Hash_Table *h;
1308 GET_CCL_RANGE (eop, ccl_prog, ic++, 0, 1308 GET_CCL_RANGE (eop, ccl_prog, ic++, 0,
1309 (VECTORP (Vtranslation_hash_table_vector) 1309 (VECTORP (Vtranslation_hash_table_vector)
@@ -1329,7 +1329,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1329 1329
1330 case CCL_LookupCharConstTbl: 1330 case CCL_LookupCharConstTbl:
1331 { 1331 {
1332 EMACS_INT eop; 1332 ptrdiff_t eop;
1333 struct Lisp_Hash_Table *h; 1333 struct Lisp_Hash_Table *h;
1334 GET_CCL_RANGE (eop, ccl_prog, ic++, 0, 1334 GET_CCL_RANGE (eop, ccl_prog, ic++, 0,
1335 (VECTORP (Vtranslation_hash_table_vector) 1335 (VECTORP (Vtranslation_hash_table_vector)
diff --git a/src/charset.h b/src/charset.h
index c2a52a38e7e..be02bc0feae 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -148,7 +148,7 @@ struct charset
148 int id; 148 int id;
149 149
150 /* Index to Vcharset_hash_table. */ 150 /* Index to Vcharset_hash_table. */
151 EMACS_INT hash_index; 151 ptrdiff_t hash_index;
152 152
153 /* Dimension of the charset: 1, 2, 3, or 4. */ 153 /* Dimension of the charset: 1, 2, 3, or 4. */
154 int dimension; 154 int dimension;
@@ -341,7 +341,7 @@ extern int emacs_mule_charset[256];
341 number of the charset. Otherwise, signal an error. */ 341 number of the charset. Otherwise, signal an error. */
342#define CHECK_CHARSET_GET_ID(x, id) \ 342#define CHECK_CHARSET_GET_ID(x, id) \
343 do { \ 343 do { \
344 int idx; \ 344 ptrdiff_t idx; \
345 \ 345 \
346 if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0) \ 346 if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0) \
347 wrong_type_argument (Qcharsetp, (x)); \ 347 wrong_type_argument (Qcharsetp, (x)); \
diff --git a/src/coding.c b/src/coding.c
index 65c8a767c2b..73a4bbc5e25 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5838,7 +5838,7 @@ coding_charset_list (struct coding_system *coding)
5838Lisp_Object 5838Lisp_Object
5839coding_system_charset_list (Lisp_Object coding_system) 5839coding_system_charset_list (Lisp_Object coding_system)
5840{ 5840{
5841 int id; 5841 ptrdiff_t id;
5842 Lisp_Object attrs, charset_list; 5842 Lisp_Object attrs, charset_list;
5843 5843
5844 CHECK_CODING_SYSTEM_GET_ID (coding_system, id); 5844 CHECK_CODING_SYSTEM_GET_ID (coding_system, id);
@@ -8076,7 +8076,7 @@ detect_coding_system (const unsigned char *src,
8076 Lisp_Object attrs, eol_type; 8076 Lisp_Object attrs, eol_type;
8077 Lisp_Object val = Qnil; 8077 Lisp_Object val = Qnil;
8078 struct coding_system coding; 8078 struct coding_system coding;
8079 int id; 8079 ptrdiff_t id;
8080 struct coding_detection_info detect_info; 8080 struct coding_detection_info detect_info;
8081 enum coding_category base_category; 8081 enum coding_category base_category;
8082 int null_byte_found = 0, eight_bit_found = 0; 8082 int null_byte_found = 0, eight_bit_found = 0;
diff --git a/src/coding.h b/src/coding.h
index 85e153dcc3a..fdf9b762e75 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -415,7 +415,7 @@ struct coding_system
415 setup_coding_system. At the early stage of building time, this 415 setup_coding_system. At the early stage of building time, this
416 value is -1 in the array coding_categories to indicate that no 416 value is -1 in the array coding_categories to indicate that no
417 coding-system of that category is yet defined. */ 417 coding-system of that category is yet defined. */
418 int id; 418 ptrdiff_t id;
419 419
420 /* Flag bits of the coding system. The meaning of each bit is common 420 /* Flag bits of the coding system. The meaning of each bit is common
421 to all types of coding systems. */ 421 to all types of coding systems. */
diff --git a/src/composite.c b/src/composite.c
index d402d5ad0c4..43041f7b381 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -179,7 +179,7 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
179 Lisp_Object id, length, components, key, *key_contents; 179 Lisp_Object id, length, components, key, *key_contents;
180 int glyph_len; 180 int glyph_len;
181 struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table); 181 struct Lisp_Hash_Table *hash_table = XHASH_TABLE (composition_hash_table);
182 EMACS_INT hash_index; 182 ptrdiff_t hash_index;
183 EMACS_UINT hash_code; 183 EMACS_UINT hash_code;
184 struct composition *cmp; 184 struct composition *cmp;
185 EMACS_INT i; 185 EMACS_INT i;
@@ -656,7 +656,7 @@ static Lisp_Object
656gstring_lookup_cache (Lisp_Object header) 656gstring_lookup_cache (Lisp_Object header)
657{ 657{
658 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); 658 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
659 EMACS_INT i = hash_lookup (h, header, NULL); 659 ptrdiff_t i = hash_lookup (h, header, NULL);
660 660
661 return (i >= 0 ? HASH_VALUE (h, i) : Qnil); 661 return (i >= 0 ? HASH_VALUE (h, i) : Qnil);
662} 662}
diff --git a/src/fns.c b/src/fns.c
index 9c9d19fe26a..fdaffe947ac 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3787,11 +3787,11 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3787 the hash code of KEY. Value is the index of the entry in H 3787 the hash code of KEY. Value is the index of the entry in H
3788 matching KEY, or -1 if not found. */ 3788 matching KEY, or -1 if not found. */
3789 3789
3790EMACS_INT 3790ptrdiff_t
3791hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash) 3791hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
3792{ 3792{
3793 EMACS_UINT hash_code; 3793 EMACS_UINT hash_code;
3794 EMACS_INT start_of_bucket; 3794 ptrdiff_t start_of_bucket;
3795 Lisp_Object idx; 3795 Lisp_Object idx;
3796 3796
3797 hash_code = h->hashfn (h, key); 3797 hash_code = h->hashfn (h, key);
@@ -3821,11 +3821,11 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
3821 HASH is a previously computed hash code of KEY. 3821 HASH is a previously computed hash code of KEY.
3822 Value is the index of the entry in H matching KEY. */ 3822 Value is the index of the entry in H matching KEY. */
3823 3823
3824EMACS_INT 3824ptrdiff_t
3825hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, 3825hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
3826 EMACS_UINT hash) 3826 EMACS_UINT hash)
3827{ 3827{
3828 EMACS_INT start_of_bucket, i; 3828 ptrdiff_t start_of_bucket, i;
3829 3829
3830 xassert ((hash & ~INTMASK) == 0); 3830 xassert ((hash & ~INTMASK) == 0);
3831 3831
@@ -4482,7 +4482,7 @@ If KEY is not found, return DFLT which defaults to nil. */)
4482 (Lisp_Object key, Lisp_Object table, Lisp_Object dflt) 4482 (Lisp_Object key, Lisp_Object table, Lisp_Object dflt)
4483{ 4483{
4484 struct Lisp_Hash_Table *h = check_hash_table (table); 4484 struct Lisp_Hash_Table *h = check_hash_table (table);
4485 EMACS_INT i = hash_lookup (h, key, NULL); 4485 ptrdiff_t i = hash_lookup (h, key, NULL);
4486 return i >= 0 ? HASH_VALUE (h, i) : dflt; 4486 return i >= 0 ? HASH_VALUE (h, i) : dflt;
4487} 4487}
4488 4488
@@ -4494,7 +4494,7 @@ VALUE. In any case, return VALUE. */)
4494 (Lisp_Object key, Lisp_Object value, Lisp_Object table) 4494 (Lisp_Object key, Lisp_Object value, Lisp_Object table)
4495{ 4495{
4496 struct Lisp_Hash_Table *h = check_hash_table (table); 4496 struct Lisp_Hash_Table *h = check_hash_table (table);
4497 EMACS_INT i; 4497 ptrdiff_t i;
4498 EMACS_UINT hash; 4498 EMACS_UINT hash;
4499 4499
4500 i = hash_lookup (h, key, &hash); 4500 i = hash_lookup (h, key, &hash);
diff --git a/src/image.c b/src/image.c
index 3a58be5d85e..974c525c4e6 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3807,8 +3807,8 @@ xpm_get_color_table_h (Lisp_Object color_table,
3807 int chars_len) 3807 int chars_len)
3808{ 3808{
3809 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 3809 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3810 int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), 3810 ptrdiff_t i =
3811 NULL); 3811 hash_lookup (table, make_unibyte_string (chars_start, chars_len), NULL);
3812 3812
3813 return i >= 0 ? HASH_VALUE (table, i) : Qnil; 3813 return i >= 0 ? HASH_VALUE (table, i) : Qnil;
3814} 3814}
diff --git a/src/lisp.h b/src/lisp.h
index 1e141dbb5d0..2d326043614 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2562,8 +2562,8 @@ EMACS_UINT sxhash (Lisp_Object, int);
2562Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, 2562Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object,
2563 Lisp_Object, Lisp_Object, Lisp_Object, 2563 Lisp_Object, Lisp_Object, Lisp_Object,
2564 Lisp_Object); 2564 Lisp_Object);
2565EMACS_INT hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); 2565ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
2566EMACS_INT hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, 2566ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
2567 EMACS_UINT); 2567 EMACS_UINT);
2568void init_weak_hash_tables (void); 2568void init_weak_hash_tables (void);
2569extern void init_fns (void); 2569extern void init_fns (void);
diff --git a/src/minibuf.c b/src/minibuf.c
index cf37c337be4..951bf028c38 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1713,7 +1713,7 @@ the values STRING, PREDICATE and `lambda'. */)
1713 (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate) 1713 (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate)
1714{ 1714{
1715 Lisp_Object regexps, tail, tem = Qnil; 1715 Lisp_Object regexps, tail, tem = Qnil;
1716 EMACS_INT i = 0; 1716 ptrdiff_t i = 0;
1717 1717
1718 CHECK_STRING (string); 1718 CHECK_STRING (string);
1719 1719