+2011-06-22 Paul Eggert <eggert@cs.ucla.edu>
+
+ * dispextern.h (struct face.stipple):
+ * image.c (x_bitmap_height, x_bitmap_width, x_bitmap_pixmap)
+ (x_bitmap_mask, x_allocate_bitmap_record)
+ (x_create_bitmap_from_data, x_create_bitmap_from_file)
+ (x_destroy_bitmap, x_destroy_all_bitmaps, x_create_bitmap_mask)
+ (x_create_bitmap_from_xpm_data):
+ * nsterm.h (struct ns_display_info.bitmaps_size, .bitmaps_last):
+ * w32term.h (struct w32_display_info.icon_bitmap_id, .bitmaps_size)
+ (.bitmaps_last):
+ * xfaces.c (load_pixmap):
+ * xterm.c (x_bitmap_icon, x_wm_set_icon_pixmap):
+ * xterm.h (struct x_display_info.icon_bitmap_id, .bitmaps_size)
+ (.bitmaps_last, struct x_output.icon_bitmap):
+ Use ptrdiff_t, not int, for bitmap indexes.
+ (x_allocate_bitmap_record): Check for size overflow.
+ * dispextern.h, lisp.h: Adjust to API changes elsewhere.
+
2011-06-21 Paul Eggert <eggert@cs.ucla.edu>
Use ptrdiff_t, not int, for overlay counts.
/* Background stipple or bitmap used for this face. This is
an id as returned from load_pixmap. */
- int stipple;
+ ptrdiff_t stipple;
#else /* not HAVE_WINDOW_SYSTEM */
/* Dummy. */
- int stipple;
+ ptrdiff_t stipple;
#endif /* not HAVE_WINDOW_SYSTEM */
#ifdef HAVE_WINDOW_SYSTEM
-extern int x_bitmap_height (struct frame *, int);
-extern int x_bitmap_width (struct frame *, int);
-extern int x_bitmap_pixmap (struct frame *, int);
+extern int x_bitmap_height (struct frame *, ptrdiff_t);
+extern int x_bitmap_width (struct frame *, ptrdiff_t);
+extern int x_bitmap_pixmap (struct frame *, ptrdiff_t);
extern void x_reference_bitmap (struct frame *, int);
-extern int x_create_bitmap_from_data (struct frame *, char *,
- unsigned int, unsigned int);
-extern int x_create_bitmap_from_file (struct frame *, Lisp_Object);
+extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *,
+ unsigned int, unsigned int);
+extern ptrdiff_t x_create_bitmap_from_file (struct frame *, Lisp_Object);
#if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK
-extern int x_create_bitmap_from_xpm_data (struct frame *f, const char **bits);
+extern ptrdiff_t x_create_bitmap_from_xpm_data (struct frame *, const char **);
#endif
#ifndef x_destroy_bitmap
-extern void x_destroy_bitmap (struct frame *, int);
+extern void x_destroy_bitmap (struct frame *, ptrdiff_t);
#endif
extern void x_destroy_all_bitmaps (Display_Info *);
-extern int x_create_bitmap_mask (struct frame * , int);
+extern int x_create_bitmap_mask (struct frame *, ptrdiff_t);
extern Lisp_Object x_find_image_file (Lisp_Object);
void x_kill_gs_process (Pixmap, struct frame *);
/* Functions to access the contents of a bitmap, given an id. */
int
-x_bitmap_height (FRAME_PTR f, int id)
+x_bitmap_height (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height;
}
int
-x_bitmap_width (FRAME_PTR f, int id)
+x_bitmap_width (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width;
}
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
int
-x_bitmap_pixmap (FRAME_PTR f, int id)
+x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id)
{
return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
}
#ifdef HAVE_X_WINDOWS
int
-x_bitmap_mask (FRAME_PTR f, int id)
+x_bitmap_mask (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask;
}
/* Allocate a new bitmap record. Returns index of new record. */
-static int
+static ptrdiff_t
x_allocate_bitmap_record (FRAME_PTR f)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int i;
+ ptrdiff_t i;
if (dpyinfo->bitmaps == NULL)
{
if (dpyinfo->bitmaps[i].refcount == 0)
return i + 1;
+ if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Bitmap_Record) / 2
+ < dpyinfo->bitmaps_size)
+ memory_full (SIZE_MAX);
dpyinfo->bitmaps_size *= 2;
dpyinfo->bitmaps
= (Bitmap_Record *) xrealloc (dpyinfo->bitmaps,
/* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
-int
+ptrdiff_t
x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int id;
+ ptrdiff_t id;
#ifdef HAVE_X_WINDOWS
Pixmap bitmap;
/* Create bitmap from file FILE for frame F. */
-int
+ptrdiff_t
x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
- int id;
+ ptrdiff_t id;
void *bitmap = ns_image_from_file (file);
if (!bitmap)
#ifdef HAVE_X_WINDOWS
unsigned int width, height;
Pixmap bitmap;
- int xhot, yhot, result, id;
+ int xhot, yhot, result;
+ ptrdiff_t id;
Lisp_Object found;
int fd;
char *filename;
/* Remove reference to bitmap with id number ID. */
void
-x_destroy_bitmap (FRAME_PTR f, int id)
+x_destroy_bitmap (FRAME_PTR f, ptrdiff_t id)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
void
x_destroy_all_bitmaps (Display_Info *dpyinfo)
{
- int i;
+ ptrdiff_t i;
Bitmap_Record *bm = dpyinfo->bitmaps;
for (i = 0; i < dpyinfo->bitmaps_last; i++, bm++)
It's nicer with some borders in this context */
int
-x_create_bitmap_mask (struct frame *f, int id)
+x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
{
Pixmap pixmap, mask;
XImagePtr ximg, mask_img;
#endif /* HAVE_XPM || HAVE_NS */
#if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK
-int
+ptrdiff_t
x_create_bitmap_from_xpm_data (struct frame *f, const char **bits)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int id, rc;
+ ptrdiff_t id;
+ int rc;
XpmAttributes attrs;
Pixmap bitmap, mask;
/* Defined in image.c */
extern Lisp_Object QCascent, QCmargin, QCrelief;
extern Lisp_Object QCconversion;
-extern int x_bitmap_mask (struct frame *, int);
+extern int x_bitmap_mask (struct frame *, ptrdiff_t);
extern void syms_of_image (void);
extern void init_image (void);
int smallest_font_height;
struct ns_bitmap_record *bitmaps;
- int bitmaps_size;
- int bitmaps_last;
+ ptrdiff_t bitmaps_size;
+ ptrdiff_t bitmaps_last;
struct image_cache *image_cache;
#endif /* HAVE_NS */
-
/* Emacs bitmap-id of the default icon bitmap for this frame.
Or -1 if none has been allocated yet. */
- int icon_bitmap_id;
+ ptrdiff_t icon_bitmap_id;
/* The root window of this screen. */
Window root_window;
struct w32_bitmap_record *bitmaps;
/* Allocated size of bitmaps field. */
- int bitmaps_size;
+ ptrdiff_t bitmaps_size;
/* Last used bitmap index. */
- int bitmaps_last;
+ ptrdiff_t bitmaps_last;
/* The frame (if any) which has the window that has keyboard focus.
Zero if none. This is examined by Ffocus_frame in w32fns.c. Note
static void set_font_frame_param (Lisp_Object, Lisp_Object);
static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *,
int, struct named_merge_point *);
-static int load_pixmap (struct frame *, Lisp_Object, unsigned *, unsigned *);
+static ptrdiff_t load_pixmap (struct frame *, Lisp_Object,
+ unsigned *, unsigned *);
static struct frame *frame_or_selected_frame (Lisp_Object, int);
static void load_face_colors (struct frame *, struct face *, Lisp_Object *);
static void free_face_colors (struct frame *, struct face *);
zero. Store the bitmap width in *W_PTR and its height in *H_PTR,
if these pointers are not null. */
-static int
+static ptrdiff_t
load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr, unsigned int *h_ptr)
{
- int bitmap_id;
+ ptrdiff_t bitmap_id;
if (NILP (name))
return 0;
interference with debugging failing X calls. */
static void x_connection_closed (Display *, const char *);
static void x_wm_set_window_state (struct frame *, int);
-static void x_wm_set_icon_pixmap (struct frame *, int);
+static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
static void x_initialize (void);
int
x_bitmap_icon (struct frame *f, Lisp_Object file)
{
- int bitmap_id;
+ ptrdiff_t bitmap_id;
if (FRAME_X_WINDOW (f) == 0)
return 1;
/* Create the GNU bitmap and mask if necessary. */
if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
{
- int rc = -1;
+ ptrdiff_t rc = -1;
#ifdef USE_GTK
}
static void
-x_wm_set_icon_pixmap (struct frame *f, int pixmap_id)
+x_wm_set_icon_pixmap (struct frame *f, ptrdiff_t pixmap_id)
{
Pixmap icon_pixmap, icon_mask;
/* Emacs bitmap-id of the default icon bitmap for this frame.
Or -1 if none has been allocated yet. */
- int icon_bitmap_id;
+ ptrdiff_t icon_bitmap_id;
/* The root window of this screen. */
Window root_window;
struct x_bitmap_record *bitmaps;
/* Allocated size of bitmaps field. */
- int bitmaps_size;
+ ptrdiff_t bitmaps_size;
/* Last used bitmap index. */
- int bitmaps_last;
+ ptrdiff_t bitmaps_last;
/* Which modifier keys are on which modifier bits?
/* If >=0, a bitmap index. The indicated bitmap is used for the
icon. */
- int icon_bitmap;
+ ptrdiff_t icon_bitmap;
/* Default ASCII font of this frame. */
struct font *font;