diff options
| author | Paul Eggert | 2011-07-19 14:39:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-19 14:39:36 -0700 |
| commit | ebfa62c01481332072f519581aaf4d8d7da49e68 (patch) | |
| tree | c62f6a866f44165112999f66f5ca7e5f30dc2af3 /src/composite.c | |
| parent | 63cf7836ae7616ce91d7eeaeac997d71609e191b (diff) | |
| download | emacs-ebfa62c01481332072f519581aaf4d8d7da49e68.tar.gz emacs-ebfa62c01481332072f519581aaf4d8d7da49e68.zip | |
Use ptrdiff_t for composition IDs.
* character.c (lisp_string_width):
* composite.c (composition_table_size, n_compositions)
(get_composition_id, composition_gstring_from_id):
* dispextern.h (struct glyph_string.cmp_id, struct composition_it.id):
* xdisp.c (BUILD_COMPOSITE_GLYPH_STRING):
* window.c (Frecenter):
Use ptrdiff_t, not int, for composition IDs.
* composite.c (get_composition_id): Check for integer overflow.
* composite.h: Adjust prototypes to match the above changes.
Diffstat (limited to 'src/composite.c')
| -rw-r--r-- | src/composite.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/composite.c b/src/composite.c index 43041f7b381..b25699b9ff4 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -142,10 +142,10 @@ Lisp_Object Qcomposition; | |||
| 142 | struct composition **composition_table; | 142 | struct composition **composition_table; |
| 143 | 143 | ||
| 144 | /* The current size of `composition_table'. */ | 144 | /* The current size of `composition_table'. */ |
| 145 | static int composition_table_size; | 145 | static ptrdiff_t composition_table_size; |
| 146 | 146 | ||
| 147 | /* Number of compositions currently made. */ | 147 | /* Number of compositions currently made. */ |
| 148 | int n_compositions; | 148 | ptrdiff_t n_compositions; |
| 149 | 149 | ||
| 150 | /* Hash table for compositions. The key is COMPONENTS-VEC of | 150 | /* Hash table for compositions. The key is COMPONENTS-VEC of |
| 151 | `composition' property. The value is the corresponding | 151 | `composition' property. The value is the corresponding |
| @@ -172,7 +172,7 @@ Lisp_Object composition_temp; | |||
| 172 | 172 | ||
| 173 | If the composition is invalid, return -1. */ | 173 | If the composition is invalid, return -1. */ |
| 174 | 174 | ||
| 175 | int | 175 | ptrdiff_t |
| 176 | get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, | 176 | get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, |
| 177 | Lisp_Object prop, Lisp_Object string) | 177 | Lisp_Object prop, Lisp_Object string) |
| 178 | { | 178 | { |
| @@ -260,18 +260,22 @@ get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, | |||
| 260 | /* Check if we have sufficient memory to store this information. */ | 260 | /* Check if we have sufficient memory to store this information. */ |
| 261 | if (composition_table_size == 0) | 261 | if (composition_table_size == 0) |
| 262 | { | 262 | { |
| 263 | composition_table_size = 256; | ||
| 264 | composition_table | 263 | composition_table |
| 265 | = (struct composition **) xmalloc (sizeof (composition_table[0]) | 264 | = (struct composition **) xmalloc (sizeof (composition_table[0]) * 256); |
| 266 | * composition_table_size); | 265 | composition_table_size = 256; |
| 267 | } | 266 | } |
| 268 | else if (composition_table_size <= n_compositions) | 267 | else if (composition_table_size <= n_compositions) |
| 269 | { | 268 | { |
| 270 | composition_table_size += 256; | 269 | if ((min (MOST_POSITIVE_FIXNUM, |
| 270 | min (PTRDIFF_MAX, SIZE_MAX) / sizeof composition_table[0]) | ||
| 271 | - 256) | ||
| 272 | < composition_table_size) | ||
| 273 | memory_full (SIZE_MAX); | ||
| 271 | composition_table | 274 | composition_table |
| 272 | = (struct composition **) xrealloc (composition_table, | 275 | = (struct composition **) xrealloc (composition_table, |
| 273 | sizeof (composition_table[0]) | 276 | sizeof (composition_table[0]) |
| 274 | * composition_table_size); | 277 | * (composition_table_size + 256)); |
| 278 | composition_table_size += 256; | ||
| 275 | } | 279 | } |
| 276 | 280 | ||
| 277 | key_contents = XVECTOR (key)->contents; | 281 | key_contents = XVECTOR (key)->contents; |
| @@ -691,7 +695,7 @@ composition_gstring_put_cache (Lisp_Object gstring, EMACS_INT len) | |||
| 691 | } | 695 | } |
| 692 | 696 | ||
| 693 | Lisp_Object | 697 | Lisp_Object |
| 694 | composition_gstring_from_id (int id) | 698 | composition_gstring_from_id (ptrdiff_t id) |
| 695 | { | 699 | { |
| 696 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); | 700 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); |
| 697 | 701 | ||