diff options
| author | Paul Eggert | 2011-08-16 11:44:32 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-16 11:44:32 -0700 |
| commit | a69fbedbd629c3e46a23095486617482fb1228c5 (patch) | |
| tree | ca92e4e98d3381e8b8b05c44219d8ca7410fc839 /src/image.c | |
| parent | 3f74064edab68e5620fade9b802e863cb110afd2 (diff) | |
| download | emacs-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/image.c')
| -rw-r--r-- | src/image.c | 29 |
1 files changed, 4 insertions, 25 deletions
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; |