aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-16 11:44:32 -0700
committerPaul Eggert2011-08-16 11:44:32 -0700
commita69fbedbd629c3e46a23095486617482fb1228c5 (patch)
treeca92e4e98d3381e8b8b05c44219d8ca7410fc839 /src
parent3f74064edab68e5620fade9b802e863cb110afd2 (diff)
downloademacs-a69fbedbd629c3e46a23095486617482fb1228c5.tar.gz
emacs-a69fbedbd629c3e46a23095486617482fb1228c5.zip
Simplify previous changes.
* image.c (x_allocate_bitmap_record, cache_image): * xselect.c (Fx_register_dnd_atom): Simplify previous changes by using xpalloc.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/image.c29
-rw-r--r--src/xselect.c12
3 files changed, 12 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 82851374283..6866daf9f38 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,11 @@
12011-08-15 Paul Eggert <eggert@cs.ucla.edu> 12011-08-16 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Integer and memory overflow issues (Bug#9196). 3 Integer and memory overflow issues (Bug#9196).
4 4
5 * image.c (x_allocate_bitmap_record, cache_image):
6 * xselect.c (Fx_register_dnd_atom):
7 Simplify previous changes by using xpalloc.
8
5 * buffer.c (overlay_str_len): Now ptrdiff_t, not EMACS_INT, 9 * buffer.c (overlay_str_len): Now ptrdiff_t, not EMACS_INT,
6 since either will do and ptrdiff_t is convenient with xpalloc. 10 since either will do and ptrdiff_t is convenient with xpalloc.
7 11
diff --git a/src/image.c b/src/image.c
index 2f39b896c0b..d10fdad1c54 100644
--- a/src/image.c
+++ b/src/image.c
@@ -216,15 +216,6 @@ x_allocate_bitmap_record (FRAME_PTR f)
216 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 216 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
217 ptrdiff_t i; 217 ptrdiff_t i;
218 218
219 if (dpyinfo->bitmaps == NULL)
220 {
221 dpyinfo->bitmaps
222 = (Bitmap_Record *) xmalloc (10 * sizeof (Bitmap_Record));
223 dpyinfo->bitmaps_size = 10;
224 dpyinfo->bitmaps_last = 1;
225 return 1;
226 }
227
228 if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size) 219 if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size)
229 return ++dpyinfo->bitmaps_last; 220 return ++dpyinfo->bitmaps_last;
230 221
@@ -232,14 +223,9 @@ x_allocate_bitmap_record (FRAME_PTR f)
232 if (dpyinfo->bitmaps[i].refcount == 0) 223 if (dpyinfo->bitmaps[i].refcount == 0)
233 return i + 1; 224 return i + 1;
234 225
235 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Bitmap_Record) / 2 226 dpyinfo->bitmaps =
236 < dpyinfo->bitmaps_size) 227 xpalloc (dpyinfo->bitmaps, &dpyinfo->bitmaps_size,
237 memory_full (SIZE_MAX); 228 10, -1, sizeof *dpyinfo->bitmaps);
238 dpyinfo->bitmaps
239 = (Bitmap_Record *) xrealloc (dpyinfo->bitmaps,
240 (dpyinfo->bitmaps_size
241 * (2 * sizeof (Bitmap_Record))));
242 dpyinfo->bitmaps_size *= 2;
243 return ++dpyinfo->bitmaps_last; 229 return ++dpyinfo->bitmaps_last;
244} 230}
245 231
@@ -1836,14 +1822,7 @@ cache_image (struct frame *f, struct image *img)
1836 1822
1837 /* If no free slot found, maybe enlarge c->images. */ 1823 /* If no free slot found, maybe enlarge c->images. */
1838 if (i == c->used && c->used == c->size) 1824 if (i == c->used && c->used == c->size)
1839 { 1825 c->images = xpalloc (c->images, &c->size, 1, -1, sizeof *c->images);
1840 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *c->images / 2 < c->size)
1841 memory_full (SIZE_MAX);
1842 c->images =
1843 (struct image **) xrealloc (c->images,
1844 c->size * (2 * sizeof *c->images));
1845 c->size *= 2;
1846 }
1847 1826
1848 /* Add IMG to c->images, and assign IMG an id. */ 1827 /* Add IMG to c->images, and assign IMG an id. */
1849 c->images[i] = img; 1828 c->images[i] = img;
diff --git a/src/xselect.c b/src/xselect.c
index f5505beffc6..77bda79007c 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2461,15 +2461,9 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2461 return Qnil; 2461 return Qnil;
2462 2462
2463 if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size) 2463 if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size)
2464 { 2464 dpyinfo->x_dnd_atoms =
2465 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *dpyinfo->x_dnd_atoms / 2 2465 xpalloc (dpyinfo->x_dnd_atoms, &dpyinfo->x_dnd_atoms_size,
2466 < dpyinfo->x_dnd_atoms_size) 2466 1, -1, sizeof *dpyinfo->x_dnd_atoms);
2467 memory_full (SIZE_MAX);
2468 dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms,
2469 (2 * sizeof *dpyinfo->x_dnd_atoms
2470 * dpyinfo->x_dnd_atoms_size));
2471 dpyinfo->x_dnd_atoms_size *= 2;
2472 }
2473 2467
2474 dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom; 2468 dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom;
2475 return Qnil; 2469 return Qnil;