Unverified Commit 70ac75f4 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/libX11_further_backports' into 3.6.x

parents 6c303d9e 70e9d346
...@@ -3446,7 +3446,7 @@ License: Expat ...@@ -3446,7 +3446,7 @@ License: Expat
FIXME FIXME
Files: nx-X11/include/extensions/xf86bigfont.h Files: nx-X11/include/extensions/xf86bigfont.h
nx-X11/include/extensions/xf86bigfstr.h nx-X11/include/extensions/xf86bigfproto.h
nx-X11/programs/Xserver/Xext/xf86bigfont.c nx-X11/programs/Xserver/Xext/xf86bigfont.c
Copyright: 1999-2000, Bruno Haible Copyright: 1999-2000, Bruno Haible
1999-2000, The XFree86 Project, Inc 1999-2000, The XFree86 Project, Inc
......
...@@ -36,7 +36,7 @@ override_dh_install: ...@@ -36,7 +36,7 @@ override_dh_install:
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/bigreqstr.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/bigreqstr.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xcmiscstr.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xcmiscstr.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/XIproto.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/XIproto.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xf86bigfstr.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xf86bigfproto.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xf86bigfont.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/xf86bigfont.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/XI.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/XI.h
rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/dpms.h rm -R debian/tmp/usr/include/$(DEB_BUILD_MULTIARCH)/nx-X11/extensions/dpms.h
......
...@@ -67,15 +67,15 @@ in this Software without prior written authorization from The Open Group. ...@@ -67,15 +67,15 @@ in this Software without prior written authorization from The Open Group.
#endif #endif
#endif /* _XFUNCPROTOBEGIN */ #endif /* _XFUNCPROTOBEGIN */
/* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && (__GNUC__ >= 4) #if defined(__GNUC__) && (__GNUC__ >= 4)
# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x))) # define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
#else #else
# define _X_SENTINEL(x) # define _X_SENTINEL(x)
# define _X_ATTRIBUTE_PRINTF(x,y)
#endif /* GNUC >= 4 */ #endif /* GNUC >= 4 */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303) /* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# define _X_EXPORT __attribute__((visibility("default"))) # define _X_EXPORT __attribute__((visibility("default")))
# define _X_HIDDEN __attribute__((visibility("hidden"))) # define _X_HIDDEN __attribute__((visibility("hidden")))
# define _X_INTERNAL __attribute__((visibility("internal"))) # define _X_INTERNAL __attribute__((visibility("internal")))
...@@ -83,18 +83,52 @@ in this Software without prior written authorization from The Open Group. ...@@ -83,18 +83,52 @@ in this Software without prior written authorization from The Open Group.
# define _X_EXPORT __global # define _X_EXPORT __global
# define _X_HIDDEN __hidden # define _X_HIDDEN __hidden
# define _X_INTERNAL __hidden # define _X_INTERNAL __hidden
#else /* not gcc >= 3.3 and not Sun Studio >= 8 */ #else /* not gcc >= 4 and not Sun Studio >= 8 */
# define _X_EXPORT # define _X_EXPORT
# define _X_HIDDEN # define _X_HIDDEN
# define _X_INTERNAL # define _X_INTERNAL
#endif /* GNUC >= 4 */
/* Branch prediction hints for individual conditionals */
/* requires xproto >= 7.0.9 */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
# define _X_LIKELY(x) __builtin_expect(!!(x), 1)
# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)
#else /* not gcc >= 3.3 */
# define _X_LIKELY(x) (x)
# define _X_UNLIKELY(x) (x)
#endif #endif
/* Bulk branch prediction hints via marking error path functions as "cold" */
/* requires xproto >= 7.0.25 */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
# define _X_COLD __attribute__((__cold__))
#else
# define _X_COLD /* nothing */
#endif
/* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301) #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)
# define _X_DEPRECATED __attribute__((deprecated)) # define _X_DEPRECATED __attribute__((deprecated))
#else /* not gcc >= 3.1 */ #else /* not gcc >= 3.1 */
# define _X_DEPRECATED # define _X_DEPRECATED
#endif #endif
/* requires xproto >= 7.0.17 */
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define _X_NORETURN __attribute((noreturn))
#else
# define _X_NORETURN
#endif /* GNUC */
/* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
#else /* not gcc >= 2.3 */
# define _X_ATTRIBUTE_PRINTF(x,y)
#endif
/* requires xproto >= 7.0.22 */ /* requires xproto >= 7.0.22 */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205) #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
#define _X_UNUSED __attribute__((__unused__)) #define _X_UNUSED __attribute__((__unused__))
...@@ -102,4 +136,31 @@ in this Software without prior written authorization from The Open Group. ...@@ -102,4 +136,31 @@ in this Software without prior written authorization from The Open Group.
#define _X_UNUSED /* */ #define _X_UNUSED /* */
#endif #endif
/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */
/* requires xproto >= 7.0.9
(introduced in 7.0.8 but didn't support all compilers until 7.0.9) */
#if defined(inline) /* assume autoconf set it correctly */ || \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \
(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))
# define _X_INLINE inline
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
# define _X_INLINE __inline__
#else
# define _X_INLINE
#endif
/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */
/* requires xproto >= 7.0.21 */
#ifndef _X_RESTRICT_KYWD
# if defined(restrict) /* assume autoconf set it correctly */ || \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
&& !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
# define _X_RESTRICT_KYWD restrict
# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
# define _X_RESTRICT_KYWD __restrict__
# else
# define _X_RESTRICT_KYWD
# endif
#endif
#endif /* _XFUNCPROTO_H_ */ #endif /* _XFUNCPROTO_H_ */
...@@ -13,7 +13,7 @@ SCREENSAVERHEADERS = saver.h saverproto.h scrnsaver.h ...@@ -13,7 +13,7 @@ SCREENSAVERHEADERS = saver.h saverproto.h scrnsaver.h
#endif #endif
#if BuildXF86BigfontExt #if BuildXF86BigfontExt
XF86BIGFONTHEADERS = xf86bigfont.h xf86bigfstr.h XF86BIGFONTHEADERS = xf86bigfont.h xf86bigfproto.h
#endif #endif
#if BuildXvExt #if BuildXvExt
XVHEADERS = Xv.h Xvlib.h Xvproto.h XVHEADERS = Xv.h Xvlib.h Xvproto.h
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
/* THIS IS NOT AN X CONSORTIUM STANDARD */ /* THIS IS NOT AN X CONSORTIUM STANDARD */
#ifndef _XF86BIGFSTR_H_ #ifndef _XF86BIGFPROTO_H_
#define _XF86BIGFSTR_H_ #define _XF86BIGFPROTO_H_
#include <nx-X11/extensions/xf86bigfont.h> #include <nx-X11/extensions/xf86bigfont.h>
...@@ -85,4 +85,4 @@ typedef struct { ...@@ -85,4 +85,4 @@ typedef struct {
/* Bit masks that can be set in the flags */ /* Bit masks that can be set in the flags */
#define XF86Bigfont_FLAGS_Shm 1 #define XF86Bigfont_FLAGS_Shm 1
#endif /* _XF86BIGFSTR_H_ */ #endif /* _XF86BIGFPROTO_H_ */
...@@ -24,7 +24,6 @@ in this Software without prior written authorization from The Open Group. ...@@ -24,7 +24,6 @@ in this Software without prior written authorization from The Open Group.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
......
...@@ -111,7 +111,7 @@ XcmsCreateCCC( ...@@ -111,7 +111,7 @@ XcmsCreateCCC(
XcmsPerScrnInfo *pNewScrnInfo; XcmsPerScrnInfo *pNewScrnInfo;
if (pDefaultCCC == NULL || if (pDefaultCCC == NULL ||
!(newccc = (XcmsCCC) Xcalloc(1, (unsigned) sizeof(XcmsCCCRec)))) { !(newccc = Xcalloc(1, sizeof(XcmsCCCRec)))) {
return(NULL); return(NULL);
} }
...@@ -144,8 +144,7 @@ XcmsCreateCCC( ...@@ -144,8 +144,7 @@ XcmsCreateCCC(
* If one exists replace the pPerScrnInfo. * If one exists replace the pPerScrnInfo.
*/ */
if ((pIMap = _XcmsGetIntensityMap(dpy, visual)) != NULL) { if ((pIMap = _XcmsGetIntensityMap(dpy, visual)) != NULL) {
if (!(pNewScrnInfo = (XcmsPerScrnInfo *) if (!(pNewScrnInfo = Xcalloc(1, sizeof(XcmsPerScrnInfo)))) {
Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
Xfree(newccc); Xfree(newccc);
return(NULL); return(NULL);
} }
......
...@@ -62,7 +62,7 @@ XChangeProperty ( ...@@ -62,7 +62,7 @@ XChangeProperty (
len = ((long)nelements + 3)>>2; len = ((long)nelements + 3)>>2;
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len); SetReqLen(req, len, len);
Data (dpy, (char *)data, nelements); Data (dpy, (_Xconst char *)data, nelements);
} /* else force BadLength */ } /* else force BadLength */
break; break;
...@@ -71,7 +71,7 @@ XChangeProperty ( ...@@ -71,7 +71,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len); SetReqLen(req, len, len);
len = (long)nelements << 1; len = (long)nelements << 1;
Data16 (dpy, (short *) data, len); Data16 (dpy, (_Xconst short *) data, len);
} /* else force BadLength */ } /* else force BadLength */
break; break;
...@@ -80,7 +80,7 @@ XChangeProperty ( ...@@ -80,7 +80,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len); SetReqLen(req, len, len);
len = (long)nelements << 2; len = (long)nelements << 2;
Data32 (dpy, (long *) data, len); Data32 (dpy, (_Xconst long *) data, len);
} /* else force BadLength */ } /* else force BadLength */
break; break;
......
...@@ -57,6 +57,7 @@ Bool XCheckTypedEvent ( ...@@ -57,6 +57,7 @@ Bool XCheckTypedEvent (
if (qelt->event.type == type) { if (qelt->event.type == type) {
*event = qelt->event; *event = qelt->event;
_XDeq(dpy, prev, qelt); _XDeq(dpy, prev, qelt);
_XStoreEventCookie(dpy, event);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return True; return True;
} }
......
...@@ -59,6 +59,7 @@ Bool XCheckTypedWindowEvent ( ...@@ -59,6 +59,7 @@ Bool XCheckTypedWindowEvent (
(qelt->event.type == type)) { (qelt->event.type == type)) {
*event = qelt->event; *event = qelt->event;
_XDeq(dpy, prev, qelt); _XDeq(dpy, prev, qelt);
_XStoreEventCookie(dpy, event);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return True; return True;
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef _CMAP_H_ #ifndef _CMAP_H_
#define _CMAP_H_ #define _CMAP_H_
#include <nx-X11/Xlib.h>
extern void extern void
_XcmsDeleteCmapRec( _XcmsDeleteCmapRec(
Display *dpy, Display *dpy,
......
...@@ -111,7 +111,7 @@ static void ResizeTable(DB db) ...@@ -111,7 +111,7 @@ static void ResizeTable(DB db)
otable = db->table; otable = db->table;
for (i = INITHASHMASK+1; (i + i) < db->numentries; ) for (i = INITHASHMASK+1; (i + i) < db->numentries; )
i += i; i += i;
db->table = (TableEntry *) Xcalloc((unsigned)i, sizeof(TableEntry)); db->table = Xcalloc(i, sizeof(TableEntry));
if (!db->table) { if (!db->table) {
db->table = otable; db->table = otable;
return; return;
...@@ -126,7 +126,7 @@ static void ResizeTable(DB db) ...@@ -126,7 +126,7 @@ static void ResizeTable(DB db)
*head = entry; *head = entry;
} }
} }
Xfree((char *) otable); Xfree(otable);
} }
static void _XFreeContextDB(Display *display) static void _XFreeContextDB(Display *display)
...@@ -140,12 +140,12 @@ static void _XFreeContextDB(Display *display) ...@@ -140,12 +140,12 @@ static void _XFreeContextDB(Display *display)
for (i = db->mask + 1, pentry = db->table ; --i >= 0; pentry++) { for (i = db->mask + 1, pentry = db->table ; --i >= 0; pentry++) {
for (entry = *pentry; entry; entry = next) { for (entry = *pentry; entry; entry = next) {
next = entry->next; next = entry->next;
Xfree((char *)entry); Xfree(entry);
} }
} }
Xfree((char *) db->table); Xfree(db->table);
_XFreeMutex(&db->linfo); _XFreeMutex(&db->linfo);
Xfree((char *) db); Xfree(db);
} }
} }
...@@ -180,13 +180,13 @@ int XSaveContext( ...@@ -180,13 +180,13 @@ int XSaveContext(
UnlockDisplay(display); UnlockDisplay(display);
} }
if (!db) { if (!db) {
db = (DB) Xmalloc(sizeof(DBRec)); db = Xmalloc(sizeof(DBRec));
if (!db) if (!db)
return XCNOMEM; return XCNOMEM;
db->mask = INITHASHMASK; db->mask = INITHASHMASK;
db->table = (TableEntry *)Xcalloc(db->mask + 1, sizeof(TableEntry)); db->table = Xcalloc(db->mask + 1, sizeof(TableEntry));
if (!db->table) { if (!db->table) {
Xfree((char *)db); Xfree(db);
return XCNOMEM; return XCNOMEM;
} }
db->numentries = 0; db->numentries = 0;
...@@ -210,7 +210,7 @@ int XSaveContext( ...@@ -210,7 +210,7 @@ int XSaveContext(
return 0; return 0;
} }
} }
entry = (TableEntry) Xmalloc(sizeof(TableEntryRec)); entry = Xmalloc(sizeof(TableEntryRec));
if (!entry) if (!entry)
return XCNOMEM; return XCNOMEM;
entry->rid = rid; entry->rid = rid;
...@@ -289,7 +289,7 @@ int XDeleteContext(Display *display, XID rid, XContext context) ...@@ -289,7 +289,7 @@ int XDeleteContext(Display *display, XID rid, XContext context)
prev = &entry->next) { prev = &entry->next) {
if (entry->rid == rid && entry->context == context) { if (entry->rid == rid && entry->context == context) {
*prev = entry->next; *prev = entry->next;
Xfree((char *) entry); Xfree(entry);
db->numentries--; db->numentries--;
if (db->numentries < db->mask && db->mask > INITHASHMASK) if (db->numentries < db->mask && db->mask > INITHASHMASK)
ResizeTable(db); ResizeTable(db);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef _CR_H_ #ifndef _CR_H_
#define _CR_H_ #define _CR_H_
#include <nx-X11/Xlib.h>
extern int _XUpdateGCCache( extern int _XUpdateGCCache(
register GC gc, register GC gc,
register unsigned long mask, register unsigned long mask,
......
...@@ -53,27 +53,28 @@ Pixmap XCreateBitmapFromData( ...@@ -53,27 +53,28 @@ Pixmap XCreateBitmapFromData(
unsigned int width, unsigned int width,
unsigned int height) unsigned int height)
{ {
XImage ximage; Pixmap pix = XCreatePixmap(display, d, width, height, 1);
GC gc; GC gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0);
Pixmap pix; if (gc == NULL) {
XFreePixmap(display, pix);
pix = XCreatePixmap(display, d, width, height, 1);
if (! (gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0)))
return (Pixmap) None; return (Pixmap) None;
ximage.height = height; } else {
ximage.width = width; XImage ximage = {
ximage.depth = 1; .height = height,
ximage.bits_per_pixel = 1; .width = width,
ximage.xoffset = 0; .depth = 1,
ximage.format = XYPixmap; .bits_per_pixel = 1,
ximage.data = (char *)data; .xoffset = 0,
ximage.byte_order = LSBFirst; .format = XYPixmap,
ximage.bitmap_unit = 8; .data = (char *) data,
ximage.bitmap_bit_order = LSBFirst; .byte_order = LSBFirst,
ximage.bitmap_pad = 8; .bitmap_unit = 8,
ximage.bytes_per_line = (width+7)/8; .bitmap_bit_order = LSBFirst,
.bitmap_pad = 8,
.bytes_per_line = (width + 7) / 8,
};
XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height); XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
XFreeGC(display, gc); XFreeGC(display, gc);
return(pix); return(pix);
}
} }
...@@ -72,7 +72,7 @@ GC XCreateGC ( ...@@ -72,7 +72,7 @@ GC XCreateGC (
register _XExtension *ext; register _XExtension *ext;
LockDisplay(dpy); LockDisplay(dpy);
if ((gc = (GC)Xmalloc (sizeof(struct _XGC))) == NULL) { if ((gc = Xmalloc (sizeof(struct _XGC))) == NULL) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return (NULL); return (NULL);
......
...@@ -58,30 +58,32 @@ Pixmap XCreatePixmapFromBitmapData( ...@@ -58,30 +58,32 @@ Pixmap XCreatePixmapFromBitmapData(
unsigned long bg, unsigned long bg,
unsigned int depth) unsigned int depth)
{ {
XImage ximage; Pixmap pix = XCreatePixmap(display, d, width, height, depth);
GC gc; XGCValues gcv = {
XGCValues gcv; .foreground = fg,
Pixmap pix; .background = bg
};
pix = XCreatePixmap(display, d, width, height, depth); GC gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
gcv.foreground = fg; if (gc == NULL) {
gcv.background = bg; XFreePixmap(display, pix);
if (! (gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv))) return (Pixmap) None;
return (Pixmap) NULL; } else {
ximage.height = height; XImage ximage = {
ximage.width = width; .height = height,
ximage.depth = 1; .width = width,
ximage.bits_per_pixel = 1; .depth = 1,
ximage.xoffset = 0; .bits_per_pixel = 1,
ximage.format = XYBitmap; .xoffset = 0,
ximage.data = data; .format = XYBitmap,
ximage.byte_order = LSBFirst; .data = data,
ximage.bitmap_unit = 8; .byte_order = LSBFirst,
ximage.bitmap_bit_order = LSBFirst; .bitmap_unit = 8,
ximage.bitmap_pad = 8; .bitmap_bit_order = LSBFirst,
ximage.bytes_per_line = (width+7)/8; .bitmap_pad = 8,
.bytes_per_line = (width + 7) / 8
};
XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height); XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
XFreeGC(display, gc); XFreeGC(display, gc);
return(pix); return(pix);
}
} }
...@@ -796,7 +796,7 @@ XcmsConvertColors( ...@@ -796,7 +796,7 @@ XcmsConvertColors(
* Make copy of array of color specifications * Make copy of array of color specifications
*/ */
if (nColors > 1) { if (nColors > 1) {
pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor)); pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
} else { } else {
pColors_tmp = &Color1; pColors_tmp = &Color1;
} }
...@@ -987,13 +987,13 @@ XcmsConvertColors( ...@@ -987,13 +987,13 @@ XcmsConvertColors(
nColors * sizeof(XcmsColor)); nColors * sizeof(XcmsColor));
} }
if (nColors > 1) { if (nColors > 1) {
Xfree((char *)pColors_tmp); Xfree(pColors_tmp);
} }
return(retval); return(retval);
Failure: Failure:
if (nColors > 1) { if (nColors > 1) {
Xfree((char *)pColors_tmp); Xfree(pColors_tmp);
} }
return(XcmsFailure); return(XcmsFailure);
} }
......
...@@ -49,7 +49,7 @@ int *XListDepths ( ...@@ -49,7 +49,7 @@ int *XListDepths (
register Depth *dp; register Depth *dp;
register int i; register int i;
depths = (int *) Xmalloc (count * sizeof(int)); depths = Xmalloc (count * sizeof(int));
if (!depths) return NULL; if (!depths) return NULL;
for (i = 0, dp = scr->depths; i < count; i++, dp++) for (i = 0, dp = scr->depths; i < count; i++, dp++)
depths[i] = dp->depth; depths[i] = dp->depth;
......
...@@ -66,6 +66,7 @@ XDrawArc( ...@@ -66,6 +66,7 @@ XDrawArc(
arc->angle1 = angle1; arc->angle1 = angle1;
arc->angle2 = angle2; arc->angle2 = angle2;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return 1; return 1;
......
...@@ -109,7 +109,7 @@ XGetErrorText( ...@@ -109,7 +109,7 @@ XGetErrorText(
if (nbytes == 0) return 0; if (nbytes == 0) return 0;
if (code <= BadImplementation && code > 0) { if (code <= BadImplementation && code > 0) {
sprintf(buf, "%d", code); snprintf(buf, sizeof(buf), "%d", code);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf, (void) XGetErrorDatabaseText(dpy, "XProtoError", buf,
_XErrorList + _XErrorOffsets[code], _XErrorList + _XErrorOffsets[code],
buffer, nbytes); buffer, nbytes);
...@@ -125,11 +125,12 @@ XGetErrorText( ...@@ -125,11 +125,12 @@ XGetErrorText(
bext = ext; bext = ext;
} }
if (!buffer[0] && bext) { if (!buffer[0] && bext) {
sprintf(buf, "%s.%d", bext->name, code - bext->codes.first_error); snprintf(buf, sizeof(buf), "%s.%d",
bext->name, code - bext->codes.first_error);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes); (void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes);
} }
if (!buffer[0]) if (!buffer[0])
sprintf(buffer, "%d", code); snprintf(buffer, nbytes, "%d", code);
return 0; return 0;
} }
...@@ -190,7 +191,7 @@ XGetErrorDatabaseText( ...@@ -190,7 +191,7 @@ XGetErrorDatabaseText(
else else
tptr = Xmalloc (tlen); tptr = Xmalloc (tlen);
if (tptr) { if (tptr) {
sprintf(tptr, "%s.%s", name, type); snprintf(tptr, tlen, "%s.%s", name, type);
XrmGetResource(db, tptr, "ErrorType.ErrorNumber", XrmGetResource(db, tptr, "ErrorType.ErrorNumber",
&type_str, &result); &type_str, &result);
if (tptr != temp) if (tptr != temp)
......
...@@ -85,10 +85,9 @@ _XParseBaseFontNameList( ...@@ -85,10 +85,9 @@ _XParseBaseFontNameList(
if (!*str) if (!*str)
return (char **)NULL; return (char **)NULL;
if (!(ptr = Xmalloc((unsigned)strlen(str) + 1))) { if (!(ptr = strdup(str))) {
return (char **)NULL; return (char **)NULL;
} }
strcpy(ptr, str);
psave = ptr; psave = ptr;
/* somebody who specifies more than XMAXLIST basefontnames will lose */ /* somebody who specifies more than XMAXLIST basefontnames will lose */
...@@ -113,7 +112,7 @@ _XParseBaseFontNameList( ...@@ -113,7 +112,7 @@ _XParseBaseFontNameList(
if (!*ptr) if (!*ptr)
break; break;
} }
if (!(list = (char **) Xmalloc((unsigned)sizeof(char *) * (*num + 1)))) { if (!(list = Xmalloc(sizeof(char *) * (*num + 1)))) {
Xfree(psave); Xfree(psave);
return (char **)NULL; return (char **)NULL;
} }
...@@ -131,10 +130,10 @@ copy_string_list( ...@@ -131,10 +130,10 @@ copy_string_list(
char **string_list_ret, **list_src, **list_dst, *dst; char **string_list_ret, **list_src, **list_dst, *dst;
int length, count; int length, count;
if (string_list == NULL) if (string_list == NULL || list_count <= 0)
return (char **) NULL; return (char **) NULL;
string_list_ret = (char **) Xmalloc(sizeof(char *) * list_count); string_list_ret = Xmalloc(sizeof(char *) * list_count);
if (string_list_ret == NULL) if (string_list_ret == NULL)
return (char **) NULL; return (char **) NULL;
...@@ -143,7 +142,7 @@ copy_string_list( ...@@ -143,7 +142,7 @@ copy_string_list(
for (length = 0; count-- > 0; list_src++) for (length = 0; count-- > 0; list_src++)
length += strlen(*list_src) + 1; length += strlen(*list_src) + 1;
dst = (char *) Xmalloc(length); dst = Xmalloc(length);
if (dst == NULL) { if (dst == NULL) {
Xfree(string_list_ret); Xfree(string_list_ret);
return (char **) NULL; return (char **) NULL;
......
...@@ -58,7 +58,7 @@ Status XFetchName ( ...@@ -58,7 +58,7 @@ Status XFetchName (
*name = (char *)data; *name = (char *)data;
return(1); return(1);
} }
if (data) Xfree ((char *)data); Xfree (data);
*name = NULL; *name = NULL;
return(0); return(0);
} }
...@@ -89,7 +89,7 @@ Status XGetIconName ( ...@@ -89,7 +89,7 @@ Status XGetIconName (
*icon_name = (char*)data; *icon_name = (char*)data;
return(1); return(1);
} }
if (data) Xfree ((char *)data); Xfree (data);
*icon_name = NULL; *icon_name = NULL;
return(0); return(0);
} }
...@@ -63,3 +63,4 @@ XFillRectangles( ...@@ -63,3 +63,4 @@ XFillRectangles(
SyncHandle(); SyncHandle();
return 1; return 1;
} }
...@@ -45,7 +45,7 @@ authorization from the X Consortium and the XFree86 Project. ...@@ -45,7 +45,7 @@ authorization from the X Consortium and the XFree86 Project.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <nx-X11/extensions/xf86bigfstr.h> #include <nx-X11/extensions/xf86bigfproto.h>
#endif #endif
#include "Xlcint.h" #include "Xlcint.h"
...@@ -166,13 +166,13 @@ XFreeFont( ...@@ -166,13 +166,13 @@ XFreeFont(
#ifdef USE_XF86BIGFONT #ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs); _XF86BigfontFreeFontMetrics(fs);
#else #else
Xfree ((char *) fs->per_char); Xfree (fs->per_char);
#endif #endif
} }
_XFreeExtData(fs->ext_data); _XFreeExtData(fs->ext_data);
if (fs->properties)
Xfree ((char *) fs->properties); Xfree (fs->properties);
Xfree ((char *) fs); Xfree (fs);
return 1; return 1;
} }
...@@ -215,7 +215,7 @@ _XQueryFont ( ...@@ -215,7 +215,7 @@ _XQueryFont (
DeqAsyncHandler(dpy, &async); DeqAsyncHandler(dpy, &async);
reply_left = reply.length - reply_left = reply.length -
((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2); ((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2);
if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) { if (! (fs = Xmalloc (sizeof (XFontStruct)))) {
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -249,7 +249,7 @@ _XQueryFont ( ...@@ -249,7 +249,7 @@ _XQueryFont (
fs->properties = Xmalloc (pbytes); fs->properties = Xmalloc (pbytes);
} }
if (! fs->properties) { if (! fs->properties) {
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -260,7 +260,6 @@ _XQueryFont ( ...@@ -260,7 +260,6 @@ _XQueryFont (
* If no characters in font, then it is a bad font, but * If no characters in font, then it is a bad font, but
* shouldn't try to read nothing. * shouldn't try to read nothing.
*/ */
/* have to unpack charinfos on some machines (CRAY) */
fs->per_char = NULL; fs->per_char = NULL;
if (reply.nCharInfos > 0){ if (reply.nCharInfos > 0){
/* nCharInfos is a CARD32 */ /* nCharInfos is a CARD32 */
...@@ -272,8 +271,8 @@ _XQueryFont ( ...@@ -272,8 +271,8 @@ _XQueryFont (
} }
} }
if (! fs->per_char) { if (! fs->per_char) {
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -324,7 +323,7 @@ _XF86BigfontCodes ( ...@@ -324,7 +323,7 @@ _XF86BigfontCodes (
if (pData) if (pData)
return (XF86BigfontCodes *) pData->private_data; return (XF86BigfontCodes *) pData->private_data;
pData = (XExtData *) Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes)); pData = Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes));
if (!pData) { if (!pData) {
/* Out of luck. */ /* Out of luck. */
return (XF86BigfontCodes *) NULL; return (XF86BigfontCodes *) NULL;
...@@ -460,7 +459,7 @@ _XF86BigfontQueryFont ( ...@@ -460,7 +459,7 @@ _XF86BigfontQueryFont (
DeqAsyncHandler(dpy, &async1); DeqAsyncHandler(dpy, &async1);
reply_left = reply.length - reply_left = reply.length -
((SIZEOF(xXF86BigfontQueryFontReply) - SIZEOF(xReply)) >> 2); ((SIZEOF(xXF86BigfontQueryFontReply) - SIZEOF(xReply)) >> 2);
if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) { if (! (fs = Xmalloc (sizeof (XFontStruct)))) {
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -494,7 +493,7 @@ _XF86BigfontQueryFont ( ...@@ -494,7 +493,7 @@ _XF86BigfontQueryFont (
fs->properties = Xmalloc (pbytes); fs->properties = Xmalloc (pbytes);
} }
if (! fs->properties) { if (! fs->properties) {
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -509,7 +508,7 @@ _XF86BigfontQueryFont ( ...@@ -509,7 +508,7 @@ _XF86BigfontQueryFont (
if (reply.nUniqCharInfos > ((ULONG_MAX / 2) / SIZEOF(xCharInfo)) || if (reply.nUniqCharInfos > ((ULONG_MAX / 2) / SIZEOF(xCharInfo)) ||
reply.nCharInfos > ((ULONG_MAX / 2) / sizeof(CARD16))) { reply.nCharInfos > ((ULONG_MAX / 2) / sizeof(CARD16))) {
Xfree(fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -523,17 +522,17 @@ _XF86BigfontQueryFont ( ...@@ -523,17 +522,17 @@ _XF86BigfontQueryFont (
nbytes = reply.nUniqCharInfos * SIZEOF(xCharInfo) nbytes = reply.nUniqCharInfos * SIZEOF(xCharInfo)
+ (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16); + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16);
pUniqCI = (xCharInfo *) Xmalloc (nbytes); pUniqCI = Xmalloc (nbytes);
if (!pUniqCI) { if (!pUniqCI) {
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
if (! (fs->per_char = (XCharStruct *) Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) { if (! (fs->per_char = Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) {
Xfree((char *) pUniqCI); Xfree(pUniqCI);
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -542,25 +541,25 @@ _XF86BigfontQueryFont ( ...@@ -542,25 +541,25 @@ _XF86BigfontQueryFont (
for (i = 0; i < reply.nCharInfos; i++) { for (i = 0; i < reply.nCharInfos; i++) {
if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) { if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) {
fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n"); fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n");
Xfree((char *) pUniqCI); Xfree(pUniqCI);
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
/* XXX the next statement won't work if short isn't 16 bits */ /* XXX the next statement won't work if short isn't 16 bits */
fs->per_char[i] = * (XCharStruct *) &pUniqCI[pIndex2UniqIndex[i]]; fs->per_char[i] = * (XCharStruct *) &pUniqCI[pIndex2UniqIndex[i]];
} }
Xfree((char *) pUniqCI); Xfree(pUniqCI);
} else { } else {
#ifdef HAS_SHM #ifdef HAS_SHM
XExtData *pData; XExtData *pData;
XEDataObject fs_union; XEDataObject fs_union;
char *addr; char *addr;
pData = (XExtData *) Xmalloc(sizeof(XExtData)); pData = Xmalloc(sizeof(XExtData));
if (!pData) { if (!pData) {
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -578,9 +577,9 @@ _XF86BigfontQueryFont ( ...@@ -578,9 +577,9 @@ _XF86BigfontQueryFont (
if ((addr = shmat(reply.shmid, NULL, SHM_RDONLY)) == (char *)-1) { if ((addr = shmat(reply.shmid, NULL, SHM_RDONLY)) == (char *)-1) {
if (extcodes->serverCapabilities & CAP_VerifiedLocal) if (extcodes->serverCapabilities & CAP_VerifiedLocal)
fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n"); fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n");
Xfree((char *) pData); Xfree(pData);
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
/* Stop requesting shared memory transport from now on. */ /* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm; extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
...@@ -589,13 +588,13 @@ _XF86BigfontQueryFont ( ...@@ -589,13 +588,13 @@ _XF86BigfontQueryFont (
if (!(extcodes->serverCapabilities & CAP_VerifiedLocal)) { if (!(extcodes->serverCapabilities & CAP_VerifiedLocal)) {
struct shmid_ds buf; struct shmid_ds buf;
if (!(shmctl(reply.shmid, IPC_STAT, &buf) >= 0 if (!(shmctl(reply.shmid, IPC_STAT, &buf) >= 0
&& reply.nCharInfos < (LONG_MAX / sizeof(XCharStruct)) && reply.nCharInfos < (INT_MAX / sizeof(XCharStruct))
&& buf.shm_segsz >= reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct) + sizeof(CARD32) && buf.shm_segsz >= reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct) + sizeof(CARD32)
&& *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) { && *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) {
shmdt(addr); shmdt(addr);
Xfree((char *) pData); Xfree(pData);
if (fs->properties) Xfree((char *) fs->properties); Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
/* Stop requesting shared memory transport from now on. */ /* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm; extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
...@@ -612,8 +611,8 @@ _XF86BigfontQueryFont ( ...@@ -612,8 +611,8 @@ _XF86BigfontQueryFont (
fs->per_char = (XCharStruct *) (addr + reply.shmsegoffset); fs->per_char = (XCharStruct *) (addr + reply.shmsegoffset);
#else #else
fprintf(stderr, "_XF86BigfontQueryFont: try recompiling libX11 with HasShm, Xserver has shm support\n"); fprintf(stderr, "_XF86BigfontQueryFont: try recompiling libX11 with HasShm, Xserver has shm support\n");
if (fs->properties) Xfree((char *) fs->properties); if (fs->properties) Xfree(fs->properties);
Xfree((char *) fs); Xfree(fs);
/* Stop requesting shared memory transport from now on. */ /* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm; extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
...@@ -639,9 +638,9 @@ _XF86BigfontFreeFontMetrics (XFontStruct *fs) ...@@ -639,9 +638,9 @@ _XF86BigfontFreeFontMetrics (XFontStruct *fs)
XF86BigfontNumber))) XF86BigfontNumber)))
shmdt ((char *) pData->private_data); shmdt ((char *) pData->private_data);
else else
Xfree ((char *) fs->per_char); Xfree (fs->per_char);
#else #else
Xfree ((char *) fs->per_char); Xfree (fs->per_char);
#endif #endif
} }
...@@ -694,14 +693,14 @@ int _XF86LoadQueryLocaleFont( ...@@ -694,14 +693,14 @@ int _XF86LoadQueryLocaleFont(
#ifdef USE_XF86BIGFONT #ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs); _XF86BigfontFreeFontMetrics(fs);
#else #else
Xfree ((char *) fs->per_char); Xfree (fs->per_char);
#endif #endif
} }
_XFreeExtData(fs->ext_data); _XFreeExtData(fs->ext_data);
if (fs->properties)
Xfree ((char *) fs->properties); Xfree (fs->properties);
*fidp = fs->fid; *fidp = fs->fid;
Xfree ((char *) fs); Xfree (fs);
} else { } else {
XFreeFont(dpy, fs); XFreeFont(dpy, fs);
} }
......
...@@ -107,7 +107,7 @@ XFontStruct **info) /* RETURN */ ...@@ -107,7 +107,7 @@ XFontStruct **info) /* RETURN */
if (! (finfo = Xmalloc(sizeof(XFontStruct) * size))) if (! (finfo = Xmalloc(sizeof(XFontStruct) * size)))
goto clearwire; goto clearwire;
if (! (flist = Xmalloc(sizeof(char *) * (size+1)))) { if (! (flist = Xmalloc(sizeof(char *) * (size+1)))) {
Xfree((char *) finfo); Xfree(finfo);
goto clearwire; goto clearwire;
} }
} }
...@@ -152,7 +152,7 @@ XFontStruct **info) /* RETURN */ ...@@ -152,7 +152,7 @@ XFontStruct **info) /* RETURN */
nbytes++; /* make first string 1 byte longer, to match XListFonts */ nbytes++; /* make first string 1 byte longer, to match XListFonts */
flist[i] = Xmalloc (nbytes); flist[i] = Xmalloc (nbytes);
if (! flist[i]) { if (! flist[i]) {
if (finfo[i].properties) Xfree((char *) finfo[i].properties); if (finfo[i].properties) Xfree(finfo[i].properties);
goto badmem; goto badmem;
} }
if (!i) { if (!i) {
...@@ -177,10 +177,10 @@ XFontStruct **info) /* RETURN */ ...@@ -177,10 +177,10 @@ XFontStruct **info) /* RETURN */
if (j == 0) if (j == 0)
flist[j]--; /* was incremented above */ flist[j]--; /* was incremented above */
Xfree(flist[j]); Xfree(flist[j]);
if (finfo[j].properties) Xfree((char *) finfo[j].properties); if (finfo[j].properties) Xfree(finfo[j].properties);
} }
if (flist) Xfree((char *) flist); Xfree(flist);
if (finfo) Xfree((char *) finfo); Xfree(finfo);
clearwire: clearwire:
/* Clear the wire. */ /* Clear the wire. */
...@@ -208,7 +208,7 @@ XFreeFontInfo ( ...@@ -208,7 +208,7 @@ XFreeFontInfo (
for (i = 1; i < actualCount; i++) { for (i = 1; i < actualCount; i++) {
Xfree (names[i]); Xfree (names[i]);
} }
Xfree((char *) names); Xfree(names);
} }
if (info) { if (info) {
for (i = 0; i < actualCount; i++) { for (i = 0; i < actualCount; i++) {
...@@ -216,12 +216,12 @@ XFreeFontInfo ( ...@@ -216,12 +216,12 @@ XFreeFontInfo (
#ifdef USE_XF86BIGFONT #ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(&info[i]); _XF86BigfontFreeFontMetrics(&info[i]);
#else #else
Xfree ((char *) info[i].per_char); Xfree (info[i].per_char);
#endif #endif
if (info[i].properties) if (info[i].properties)
Xfree ((char *) info[i].properties); Xfree (info[i].properties);
} }
Xfree((char *) info); Xfree(info);
} }
return 1; return 1;
} }
...@@ -47,7 +47,7 @@ int *actualCount) /* RETURN */ ...@@ -47,7 +47,7 @@ int *actualCount) /* RETURN */
int count = 0; int count = 0;
xListFontsReply rep; xListFontsReply rep;
register xListFontsReq *req; register xListFontsReq *req;
unsigned long rlen; unsigned long rlen = 0;
LockDisplay(dpy); LockDisplay(dpy);
GetReq(ListFonts, req); GetReq(ListFonts, req);
...@@ -66,15 +66,15 @@ int *actualCount) /* RETURN */ ...@@ -66,15 +66,15 @@ int *actualCount) /* RETURN */
if (rep.nFonts) { if (rep.nFonts) {
flist = Xmalloc (rep.nFonts * sizeof(char *)); flist = Xmalloc (rep.nFonts * sizeof(char *));
if (rep.length < (LONG_MAX >> 2)) { if (rep.length > 0 && rep.length < (INT_MAX >> 2)) {
rlen = rep.length << 2; rlen = rep.length << 2;
ch = Xmalloc(rlen + 1); ch = Xmalloc(rlen + 1);
/* +1 to leave room for last null-terminator */ /* +1 to leave room for last null-terminator */
} }
if ((! flist) || (! ch)) { if ((! flist) || (! ch)) {
if (flist) Xfree((char *) flist); Xfree(flist);
if (ch) Xfree(ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
*actualCount = 0; *actualCount = 0;
UnlockDisplay(dpy); UnlockDisplay(dpy);
...@@ -93,11 +93,22 @@ int *actualCount) /* RETURN */ ...@@ -93,11 +93,22 @@ int *actualCount) /* RETURN */
if (ch + length < chend) { if (ch + length < chend) {
flist[i] = ch + 1; /* skip over length */ flist[i] = ch + 1; /* skip over length */
ch += length + 1; /* find next length ... */ ch += length + 1; /* find next length ... */
if (ch <= chend) {
length = *(unsigned char *)ch; length = *(unsigned char *)ch;
*ch = '\0'; /* and replace with null-termination */ *ch = '\0'; /* and replace with null-termination */
count++; count++;
} else } else {
flist[i] = NULL; Xfree(flist);
flist = NULL;
count = 0;
break;
}
} else {
Xfree(flist);
flist = NULL;
count = 0;
break;
}
} }
} }
*actualCount = count; *actualCount = count;
...@@ -116,7 +127,7 @@ XFreeFontNames(char **list) ...@@ -116,7 +127,7 @@ XFreeFontNames(char **list)
Xfree (*names); Xfree (*names);
} }
Xfree (list[0]-1); Xfree (list[0]-1);
Xfree ((char *)list); Xfree (list);
} }
return 1; return 1;
} }
...@@ -36,9 +36,9 @@ _XFreeExtData (XExtData *extension) ...@@ -36,9 +36,9 @@ _XFreeExtData (XExtData *extension)
while (extension) { while (extension) {
if (extension->free_private) if (extension->free_private)
(*extension->free_private)(extension); (*extension->free_private)(extension);
else Xfree ((char *)extension->private_data); else Xfree (extension->private_data);
temp = extension->next; temp = extension->next;
Xfree ((char *)extension); Xfree (extension);
extension = temp; extension = temp;
} }
return 0; return 0;
......
...@@ -44,6 +44,7 @@ XFreeGC ( ...@@ -44,6 +44,7 @@ XFreeGC (
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
_XFreeExtData(gc->ext_data); _XFreeExtData(gc->ext_data);
Xfree ((char *) gc); Xfree (gc);
return 1; return 1;
} }
...@@ -46,7 +46,7 @@ char *_XGetAtomName( ...@@ -46,7 +46,7 @@ char *_XGetAtomName(
for (idx = TABLESIZE; --idx >= 0; ) { for (idx = TABLESIZE; --idx >= 0; ) {
if ((e = *table++) && (e->atom == atom)) { if ((e = *table++) && (e->atom == atom)) {
idx = strlen(EntryName(e)) + 1; idx = strlen(EntryName(e)) + 1;
if ((name = (char *)Xmalloc(idx))) if ((name = Xmalloc(idx)))
strcpy(name, EntryName(e)); strcpy(name, EntryName(e));
return name; return name;
} }
...@@ -73,7 +73,7 @@ char *XGetAtomName( ...@@ -73,7 +73,7 @@ char *XGetAtomName(
SyncHandle(); SyncHandle();
return(NULL); return(NULL);
} }
if ((name = (char *) Xmalloc(rep.nameLength+1))) { if ((name = Xmalloc(rep.nameLength + 1))) {
_XReadPad(dpy, name, (long)rep.nameLength); _XReadPad(dpy, name, (long)rep.nameLength);
name[rep.nameLength] = '\0'; name[rep.nameLength] = '\0';
_XUpdateAtomCache(dpy, name, atom, 0, -1, 0); _XUpdateAtomCache(dpy, name, atom, 0, -1, 0);
...@@ -124,7 +124,7 @@ Bool _XGetAtomNameHandler( ...@@ -124,7 +124,7 @@ Bool _XGetAtomNameHandler(
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2, (SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2,
False); False);
state->names[state->idx] = (char *) Xmalloc(repl->nameLength+1); state->names[state->idx] = Xmalloc(repl->nameLength + 1);
_XGetAsyncData(dpy, state->names[state->idx], buf, len, _XGetAsyncData(dpy, state->names[state->idx], buf, len,
SIZEOF(xGetAtomNameReply), repl->nameLength, SIZEOF(xGetAtomNameReply), repl->nameLength,
repl->length << 2); repl->length << 2);
...@@ -170,7 +170,7 @@ XGetAtomNames ( ...@@ -170,7 +170,7 @@ XGetAtomNames (
} }
if (missed >= 0) { if (missed >= 0) {
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if ((names_return[missed] = (char *) Xmalloc(rep.nameLength+1))) { if ((names_return[missed] = Xmalloc(rep.nameLength + 1))) {
_XReadPad(dpy, names_return[missed], (long)rep.nameLength); _XReadPad(dpy, names_return[missed], (long)rep.nameLength);
names_return[missed][rep.nameLength] = '\0'; names_return[missed][rep.nameLength] = '\0';
_XUpdateAtomCache(dpy, names_return[missed], atoms[missed], _XUpdateAtomCache(dpy, names_return[missed], atoms[missed],
......
...@@ -87,7 +87,7 @@ GetHomeDir( ...@@ -87,7 +87,7 @@ GetHomeDir(
len2 = strlen (ptr2); len2 = strlen (ptr2);
} }
if ((len1 + len2 + 1) < len) if ((len1 + len2 + 1) < len)
sprintf (dest, "%s%s", ptr1, (ptr2) ? ptr2 : ""); snprintf (dest, len, "%s%s", ptr1, (ptr2) ? ptr2 : "");
else else
*dest = '\0'; *dest = '\0';
#else #else
......
...@@ -35,7 +35,7 @@ char **XGetFontPath( ...@@ -35,7 +35,7 @@ char **XGetFontPath(
int *npaths) /* RETURN */ int *npaths) /* RETURN */
{ {
xGetFontPathReply rep; xGetFontPathReply rep;
unsigned long nbytes; unsigned long nbytes = 0;
char **flist = NULL; char **flist = NULL;
char *ch = NULL; char *ch = NULL;
char *chend; char *chend;
...@@ -50,15 +50,15 @@ char **XGetFontPath( ...@@ -50,15 +50,15 @@ char **XGetFontPath(
if (rep.nPaths) { if (rep.nPaths) {
flist = Xmalloc(rep.nPaths * sizeof (char *)); flist = Xmalloc(rep.nPaths * sizeof (char *));
if (rep.length < (LONG_MAX >> 2)) { if (rep.length < (INT_MAX >> 2)) {
nbytes = (unsigned long) rep.length << 2; nbytes = (unsigned long) rep.length << 2;
ch = Xmalloc (nbytes + 1); ch = Xmalloc (nbytes + 1);
/* +1 to leave room for last null-terminator */ /* +1 to leave room for last null-terminator */
} }
if ((! flist) || (! ch)) { if ((! flist) || (! ch)) {
if (flist) Xfree((char *) flist); Xfree(flist);
if (ch) Xfree(ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
...@@ -93,7 +93,7 @@ XFreeFontPath (char **list) ...@@ -93,7 +93,7 @@ XFreeFontPath (char **list)
{ {
if (list != NULL) { if (list != NULL) {
Xfree (list[0]-1); Xfree (list[0]-1);
Xfree ((char *)list); Xfree (list);
} }
return 1; return 1;
} }
...@@ -29,7 +29,8 @@ in this Software without prior written authorization from The Open Group. ...@@ -29,7 +29,8 @@ in this Software without prior written authorization from The Open Group.
#endif #endif
#include "Xlibint.h" #include "Xlibint.h"
Bool XGetFontProperty ( Bool
XGetFontProperty(
XFontStruct *fs, XFontStruct *fs,
register Atom name, register Atom name,
unsigned long *valuePtr) unsigned long *valuePtr)
...@@ -39,6 +40,7 @@ Bool XGetFontProperty ( ...@@ -39,6 +40,7 @@ Bool XGetFontProperty (
become a binary search. */ become a binary search. */
register XFontProp *prop = fs->properties; register XFontProp *prop = fs->properties;
register XFontProp *last = prop + fs->n_properties; register XFontProp *last = prop + fs->n_properties;
while (prop != last) { while (prop != last) {
if (prop->name == name) { if (prop->name == name) {
*valuePtr = prop->card32; *valuePtr = prop->card32;
...@@ -47,6 +49,4 @@ Bool XGetFontProperty ( ...@@ -47,6 +49,4 @@ Bool XGetFontProperty (
prop++; prop++;
} }
return (0); return (0);
} }
...@@ -75,7 +75,7 @@ Status XGetSizeHints ( ...@@ -75,7 +75,7 @@ Status XGetSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) || if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) { (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
if (prop != NULL) Xfree ((char *)prop); Xfree (prop);
return(0); return(0);
} }
hints->flags = (prop->flags & (USPosition|USSize|PAllHints)); hints->flags = (prop->flags & (USPosition|USSize|PAllHints));
...@@ -93,7 +93,7 @@ Status XGetSizeHints ( ...@@ -93,7 +93,7 @@ Status XGetSizeHints (
hints->min_aspect.y = cvtINT32toInt (prop->minAspectY); hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX); hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY); hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
Xfree((char *)prop); Xfree(prop);
return(1); return(1);
} }
...@@ -124,11 +124,11 @@ XWMHints *XGetWMHints ( ...@@ -124,11 +124,11 @@ XWMHints *XGetWMHints (
if ((actual_type != XA_WM_HINTS) || if ((actual_type != XA_WM_HINTS) ||
(nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) { (nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) {
if (prop != NULL) Xfree ((char *)prop); Xfree (prop);
return(NULL); return(NULL);
} }
/* static copies not allowed in library, due to reentrancy constraint*/ /* static copies not allowed in library, due to reentrancy constraint*/
if ((hints = (XWMHints *) Xcalloc (1, (unsigned) sizeof(XWMHints)))) { if ((hints = Xcalloc (1, sizeof(XWMHints)))) {
hints->flags = prop->flags; hints->flags = prop->flags;
hints->input = (prop->input ? True : False); hints->input = (prop->input ? True : False);
hints->initial_state = cvtINT32toInt (prop->initialState); hints->initial_state = cvtINT32toInt (prop->initialState);
...@@ -142,7 +142,7 @@ XWMHints *XGetWMHints ( ...@@ -142,7 +142,7 @@ XWMHints *XGetWMHints (
else else
hints->window_group = 0; hints->window_group = 0;
} }
Xfree ((char *)prop); Xfree (prop);
return(hints); return(hints);
} }
...@@ -196,16 +196,15 @@ Status XGetIconSizes ( ...@@ -196,16 +196,15 @@ Status XGetIconSizes (
(nitems < NumPropIconSizeElements) || (nitems < NumPropIconSizeElements) ||
(nitems % NumPropIconSizeElements != 0) || (nitems % NumPropIconSizeElements != 0) ||
(actual_format != 32)) { (actual_format != 32)) {
if (prop != NULL) Xfree ((char *)prop); Xfree (prop);
return(0); return(0);
} }
/* static copies not allowed in library, due to reentrancy constraint*/ /* static copies not allowed in library, due to reentrancy constraint*/
nitems /= NumPropIconSizeElements; nitems /= NumPropIconSizeElements;
if (! (hp = hints = (XIconSize *) if (! (hp = hints = Xcalloc (nitems, sizeof(XIconSize)))) {
Xcalloc ((unsigned) nitems, (unsigned) sizeof(XIconSize)))) { Xfree (prop);
if (prop) Xfree ((char *) prop);
return 0; return 0;
} }
...@@ -222,7 +221,7 @@ Status XGetIconSizes ( ...@@ -222,7 +221,7 @@ Status XGetIconSizes (
} }
*count = nitems; *count = nitems;
*size_list = hints; *size_list = hints;
Xfree ((char *)prop); Xfree (prop);
return(1); return(1);
} }
...@@ -240,7 +239,7 @@ Status XGetCommand ( ...@@ -240,7 +239,7 @@ Status XGetCommand (
if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0; if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0;
if (tp.encoding != XA_STRING || tp.format != 8) { if (tp.encoding != XA_STRING || tp.format != 8) {
if (tp.value) Xfree ((char *) tp.value); Xfree (tp.value);
return 0; return 0;
} }
...@@ -255,11 +254,11 @@ Status XGetCommand ( ...@@ -255,11 +254,11 @@ Status XGetCommand (
* create a string list and return if successful * create a string list and return if successful
*/ */
if (!XTextPropertyToStringList (&tp, &argv, &argc)) { if (!XTextPropertyToStringList (&tp, &argv, &argc)) {
if (tp.value) Xfree ((char *) tp.value); Xfree (tp.value);
return (0); return (0);
} }
if (tp.value) Xfree ((char *) tp.value); Xfree (tp.value);
*argvp = argv; *argvp = argv;
*argcp = argc; *argcp = argc;
return 1; return 1;
...@@ -292,7 +291,7 @@ XGetTransientForHint( ...@@ -292,7 +291,7 @@ XGetTransientForHint(
return (1); return (1);
} }
*propWindow = None; *propWindow = None;
if (data) Xfree( (char *) data); Xfree( (char *) data);
return(0); return(0);
} }
...@@ -317,23 +316,23 @@ XGetClassHint( ...@@ -317,23 +316,23 @@ XGetClassHint(
if ( (actual_type == XA_STRING) && (actual_format == 8) ) { if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
len_name = strlen((char *) data); len_name = strlen((char *) data);
if (! (classhint->res_name = Xmalloc((unsigned) (len_name+1)))) { if (! (classhint->res_name = Xmalloc(len_name + 1))) {
Xfree((char *) data); Xfree(data);
return (0); return (0);
} }
strcpy(classhint->res_name, (char *) data); strcpy(classhint->res_name, (char *) data);
if (len_name == nitems) len_name--; if (len_name == nitems) len_name--;
len_class = strlen((char *) (data+len_name+1)); len_class = strlen((char *) (data+len_name+1));
if (! (classhint->res_class = Xmalloc((unsigned) (len_class+1)))) { if (! (classhint->res_class = Xmalloc(len_class + 1))) {
Xfree(classhint->res_name); Xfree(classhint->res_name);
classhint->res_name = (char *) NULL; classhint->res_name = (char *) NULL;
Xfree((char *) data); Xfree(data);
return (0); return (0);
} }
strcpy(classhint->res_class, (char *) (data+len_name+1)); strcpy(classhint->res_class, (char *) (data+len_name+1));
Xfree( (char *) data); Xfree( (char *) data);
return(1); return(1);
} }
if (data) Xfree( (char *) data); Xfree( (char *) data);
return(0); return(0);
} }
...@@ -59,6 +59,7 @@ XImage *XGetImage ( ...@@ -59,6 +59,7 @@ XImage *XGetImage (
char *data; char *data;
unsigned long nbytes; unsigned long nbytes;
XImage *image; XImage *image;
int planes;
LockDisplay(dpy); LockDisplay(dpy);
GetReq (GetImage, req); GetReq (GetImage, req);
/* /*
...@@ -91,18 +92,28 @@ XImage *XGetImage ( ...@@ -91,18 +92,28 @@ XImage *XGetImage (
return (XImage *) NULL; return (XImage *) NULL;
} }
_XReadPad (dpy, data, nbytes); _XReadPad (dpy, data, nbytes);
if (format == XYPixmap) if (format == XYPixmap) {
image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual), image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual),
Ones (plane_mask & Ones (plane_mask &
(((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))), (((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))),
format, 0, data, width, height, dpy->bitmap_pad, 0); format, 0, data, width, height, dpy->bitmap_pad, 0);
else /* format == ZPixmap */ planes = image->depth;
} else { /* format == ZPixmap */
image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual), image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual),
rep.depth, ZPixmap, 0, data, width, height, rep.depth, ZPixmap, 0, data, width, height,
_XGetScanlinePad(dpy, (int) rep.depth), 0); _XGetScanlinePad(dpy, (int) rep.depth), 0);
planes = 1;
}
if (!image) if (!image)
Xfree(data); Xfree(data);
if (planes < 1 || image->height < 1 || image->bytes_per_line < 1 ||
INT_MAX / image->height <= image->bytes_per_line ||
INT_MAX / planes <= image->height * image->bytes_per_line ||
nbytes < planes * image->height * image->bytes_per_line) {
XDestroyImage(image);
image = NULL;
}
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return (image); return (image);
......
...@@ -83,7 +83,7 @@ Status XGetWMSizeHints ( ...@@ -83,7 +83,7 @@ Status XGetWMSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) || if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) { (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
if (prop != NULL) Xfree ((char *)prop); Xfree (prop);
return False; return False;
} }
...@@ -112,7 +112,7 @@ Status XGetWMSizeHints ( ...@@ -112,7 +112,7 @@ Status XGetWMSizeHints (
*supplied |= (PBaseSize | PWinGravity); *supplied |= (PBaseSize | PWinGravity);
} }
hints->flags &= (*supplied); /* get rid of unwanted bits */ hints->flags &= (*supplied); /* get rid of unwanted bits */
Xfree((char *)prop); Xfree(prop);
return True; return True;
} }
......
...@@ -47,7 +47,7 @@ XGetWindowProperty( ...@@ -47,7 +47,7 @@ XGetWindowProperty(
{ {
xGetPropertyReply reply; xGetPropertyReply reply;
register xGetPropertyReq *req; register xGetPropertyReq *req;
xError error; xError error = {0};
/* Always initialize return values, in case callers fail to initialize /* Always initialize return values, in case callers fail to initialize
them and fail to check the return code for an error. */ them and fail to check the return code for an error. */
......
...@@ -63,7 +63,7 @@ Status XGetRGBColormaps ( ...@@ -63,7 +63,7 @@ Status XGetRGBColormaps (
/* if wrong type or format, or too small for us, then punt */ /* if wrong type or format, or too small for us, then punt */
if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) || if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) ||
(nitems < OldNumPropStandardColormapElements)) { (nitems < OldNumPropStandardColormapElements)) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
...@@ -78,7 +78,7 @@ Status XGetRGBColormaps ( ...@@ -78,7 +78,7 @@ Status XGetRGBColormaps (
Screen *sp = _XScreenOfWindow (dpy, w); Screen *sp = _XScreenOfWindow (dpy, w);
if (!sp) { if (!sp) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
def_visual = sp->root_visual->visualid; def_visual = sp->root_visual->visualid;
...@@ -90,7 +90,7 @@ Status XGetRGBColormaps ( ...@@ -90,7 +90,7 @@ Status XGetRGBColormaps (
ncmaps = (nitems / NumPropStandardColormapElements); ncmaps = (nitems / NumPropStandardColormapElements);
if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) != if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) !=
nitems) { nitems) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
} }
...@@ -99,10 +99,9 @@ Status XGetRGBColormaps ( ...@@ -99,10 +99,9 @@ Status XGetRGBColormaps (
/* /*
* allocate array * allocate array
*/ */
cmaps = (XStandardColormap *) Xmalloc (ncmaps * cmaps = Xmalloc (ncmaps * sizeof (XStandardColormap));
sizeof (XStandardColormap));
if (!cmaps) { if (!cmaps) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
...@@ -127,7 +126,7 @@ Status XGetRGBColormaps ( ...@@ -127,7 +126,7 @@ Status XGetRGBColormaps (
map->killid = (old_style ? None : prop->killid); map->killid = (old_style ? None : prop->killid);
} }
} }
Xfree ((char *) data); Xfree (data);
*stdcmap = cmaps; *stdcmap = cmaps;
*count = ncmaps; *count = ncmaps;
return True; return True;
......
...@@ -81,7 +81,7 @@ Status XGetStandardColormap ( ...@@ -81,7 +81,7 @@ Status XGetStandardColormap (
int i; int i;
if (!sp) { if (!sp) {
if (stdcmaps) Xfree ((char *) stdcmaps); Xfree (stdcmaps);
return False; return False;
} }
vid = sp->root_visual->visualid; vid = sp->root_visual->visualid;
...@@ -91,7 +91,7 @@ Status XGetStandardColormap ( ...@@ -91,7 +91,7 @@ Status XGetStandardColormap (
} }
if (i == nstdcmaps) { /* not found */ if (i == nstdcmaps) { /* not found */
Xfree ((char *) stdcmaps); Xfree (stdcmaps);
return False; return False;
} }
use = &stdcmaps[i]; use = &stdcmaps[i];
...@@ -111,7 +111,7 @@ Status XGetStandardColormap ( ...@@ -111,7 +111,7 @@ Status XGetStandardColormap (
cmap->blue_mult = use->blue_mult; cmap->blue_mult = use->blue_mult;
cmap->base_pixel = use->base_pixel; cmap->base_pixel = use->base_pixel;
Xfree ((char *) stdcmaps); /* don't need alloced memory */ Xfree (stdcmaps); /* don't need alloced memory */
} }
return stat; return stat;
} }
...@@ -77,7 +77,7 @@ Status XGetWMColormapWindows ( ...@@ -77,7 +77,7 @@ Status XGetWMColormapWindows (
return False; return False;
if (actual_type != XA_WINDOW || actual_format != 32) { if (actual_type != XA_WINDOW || actual_format != 32) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
......
...@@ -77,7 +77,7 @@ Status XGetWMProtocols ( ...@@ -77,7 +77,7 @@ Status XGetWMProtocols (
return False; return False;
if (actual_type != XA_ATOM || actual_format != 32) { if (actual_type != XA_ATOM || actual_format != 32) {
if (data) Xfree ((char *) data); Xfree (data);
return False; return False;
} }
......
...@@ -176,13 +176,13 @@ TekHVC_ParseString( ...@@ -176,13 +176,13 @@ TekHVC_ParseString(
* XcmsSuccess if valid. * XcmsSuccess if valid.
*/ */
{ {
int n; size_t n;
char *pchar; char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) { if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure); return(XcmsFailure);
} }
n = (int)(pchar - spec); n = (size_t)(pchar - spec);
/* /*
* Check for proper prefix. * Check for proper prefix.
...@@ -349,7 +349,7 @@ XcmsTekHVCToCIEuvY( ...@@ -349,7 +349,7 @@ XcmsTekHVCToCIEuvY(
XcmsCIEuvY uvY_return; XcmsCIEuvY uvY_return;
XcmsFloat tempHue, u, v; XcmsFloat tempHue, u, v;
XcmsFloat tmpVal; XcmsFloat tmpVal;
register int i; unsigned int i;
/* /*
* Check arguments * Check arguments
...@@ -468,7 +468,7 @@ XcmsCIEuvYToTekHVC( ...@@ -468,7 +468,7 @@ XcmsCIEuvYToTekHVC(
XcmsColor *pColor = pColors_in_out; XcmsColor *pColor = pColors_in_out;
XcmsColor whitePt; XcmsColor whitePt;
XcmsTekHVC HVC_return; XcmsTekHVC HVC_return;
register int i; unsigned int i;
/* /*
* Check arguments * Check arguments
......
...@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group. ...@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group.
*/ */
/* /*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Copyright 2004 Oracle and/or its affiliates. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
......
...@@ -128,7 +128,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return) ...@@ -128,7 +128,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
return; return;
} }
args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg)); args = Xmalloc(((unsigned)max_count + 1) * sizeof(XIMArg));
*args_return = args; *args_return = args;
if (!args) return; if (!args) return;
...@@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...) ...@@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
char *ret; char *ret = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -185,8 +185,9 @@ XSetIMValues(XIM im, ...) ...@@ -185,8 +185,9 @@ XSetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
if (im && im->methods)
ret = (*im->methods->set_values) (im, args); ret = (*im->methods->set_values) (im, args);
if (args) Xfree((char *)args); Xfree(args);
return ret; return ret;
} }
...@@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...) ...@@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
char *ret; char *ret = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -212,8 +213,9 @@ XGetIMValues(XIM im, ...) ...@@ -212,8 +213,9 @@ XGetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
if (im && im->methods)
ret = (*im->methods->get_values) (im, args); ret = (*im->methods->get_values) (im, args);
if (args) Xfree((char *)args); Xfree(args);
return ret; return ret;
} }
...@@ -228,7 +230,7 @@ XCreateIC(XIM im, ...) ...@@ -228,7 +230,7 @@ XCreateIC(XIM im, ...)
va_list var; va_list var;
int total_count; int total_count;
XIMArg *args; XIMArg *args;
XIC ic; XIC ic = NULL;
/* /*
* so count the stuff dangling here * so count the stuff dangling here
...@@ -244,8 +246,9 @@ XCreateIC(XIM im, ...) ...@@ -244,8 +246,9 @@ XCreateIC(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args); _XIMVaToNestedList(var, total_count, &args);
va_end(var); va_end(var);
if (im && im->methods)
ic = (XIC) (*im->methods->create_ic) (im, args); ic = (XIC) (*im->methods->create_ic) (im, args);
if (args) Xfree((char *)args); Xfree(args);
if (ic) { if (ic) {
ic->core.next = im->core.ic_chain; ic->core.next = im->core.ic_chain;
im->core.ic_chain = ic; im->core.ic_chain = ic;
...@@ -271,7 +274,7 @@ XDestroyIC(XIC ic) ...@@ -271,7 +274,7 @@ XDestroyIC(XIC ic)
} }
} }
} }
Xfree ((char *) ic); Xfree (ic);
} }
char * char *
...@@ -300,7 +303,7 @@ XGetICValues(XIC ic, ...) ...@@ -300,7 +303,7 @@ XGetICValues(XIC ic, ...)
va_end(var); va_end(var);
ret = (*ic->methods->get_values) (ic, args); ret = (*ic->methods->get_values) (ic, args);
if (args) Xfree((char *)args); Xfree(args);
return ret; return ret;
} }
...@@ -330,7 +333,7 @@ XSetICValues(XIC ic, ...) ...@@ -330,7 +333,7 @@ XSetICValues(XIC ic, ...)
va_end(var); va_end(var);
ret = (*ic->methods->set_values) (ic, args); ret = (*ic->methods->set_values) (ic, args);
if (args) Xfree((char *)args); Xfree(args);
return ret; return ret;
} }
......
...@@ -134,7 +134,7 @@ XCloseIM(XIM im) ...@@ -134,7 +134,7 @@ XCloseIM(XIM im)
s = (im->methods->close) (im); s = (im->methods->close) (im);
for (ic = im->core.ic_chain; ic; ic = ic->core.next) for (ic = im->core.ic_chain; ic; ic = ic->core.next)
ic->core.im = (XIM)NULL; ic->core.im = (XIM)NULL;
Xfree ((char *) im); Xfree (im);
_XCloseLC (lcd); _XCloseLC (lcd);
return (s); return (s);
} }
......
...@@ -67,19 +67,23 @@ Status XIconifyWindow ( ...@@ -67,19 +67,23 @@ Status XIconifyWindow (
Window w, Window w,
int screen) int screen)
{ {
XClientMessageEvent ev;
Window root = RootWindow (dpy, screen);
Atom prop; Atom prop;
prop = XInternAtom (dpy, "WM_CHANGE_STATE", False); prop = XInternAtom (dpy, "WM_CHANGE_STATE", False);
if (prop == None) return False; if (prop == None)
return False;
else {
XClientMessageEvent ev = {
.type = ClientMessage,
.window = w,
.message_type = prop,
.format = 32,
.data.l[0] = IconicState
};
Window root = RootWindow (dpy, screen);
ev.type = ClientMessage;
ev.window = w;
ev.message_type = prop;
ev.format = 32;
ev.data.l[0] = IconicState;
return (XSendEvent (dpy, root, False, return (XSendEvent (dpy, root, False,
SubstructureRedirectMask|SubstructureNotifyMask, SubstructureRedirectMask|SubstructureNotifyMask,
(XEvent *)&ev)); (XEvent *)&ev));
}
} }
...@@ -61,13 +61,13 @@ XcmsFormatOfPrefix(char *prefix) ...@@ -61,13 +61,13 @@ XcmsFormatOfPrefix(char *prefix)
XcmsColorSpace **papColorSpaces; XcmsColorSpace **papColorSpaces;
char string_buf[64]; char string_buf[64];
char *string_lowered; char *string_lowered;
int len; size_t len;
/* /*
* While copying prefix to string_lowered, convert to lowercase * While copying prefix to string_lowered, convert to lowercase
*/ */
if ((len = strlen(prefix)) >= sizeof(string_buf)) { if ((len = strlen(prefix)) >= sizeof(string_buf)) {
string_lowered = (char *) Xmalloc(len+1); string_lowered = Xmalloc(len+1);
} else { } else {
string_lowered = string_buf; string_lowered = string_buf;
} }
......
...@@ -332,7 +332,7 @@ XImage *XCreateImage ( ...@@ -332,7 +332,7 @@ XImage *XCreateImage (
(xpad != 8 && xpad != 16 && xpad != 32) || (xpad != 8 && xpad != 16 && xpad != 32) ||
offset < 0) offset < 0)
return (XImage *) NULL; return (XImage *) NULL;
if ((image = (XImage *) Xcalloc(1, (unsigned) sizeof(XImage))) == NULL) if ((image = Xcalloc(1, sizeof(XImage))) == NULL)
return (XImage *) NULL; return (XImage *) NULL;
image->width = width; image->width = width;
...@@ -372,6 +372,7 @@ XImage *XCreateImage ( ...@@ -372,6 +372,7 @@ XImage *XCreateImage (
if (image_bytes_per_line == 0) { if (image_bytes_per_line == 0) {
image->bytes_per_line = min_bytes_per_line; image->bytes_per_line = min_bytes_per_line;
} else if (image_bytes_per_line < min_bytes_per_line) { } else if (image_bytes_per_line < min_bytes_per_line) {
Xfree(image);
return NULL; return NULL;
} else { } else {
image->bytes_per_line = image_bytes_per_line; image->bytes_per_line = image_bytes_per_line;
...@@ -433,9 +434,9 @@ Status XInitImage (XImage *image) ...@@ -433,9 +434,9 @@ Status XInitImage (XImage *image)
static int _XDestroyImage (XImage *ximage) static int _XDestroyImage (XImage *ximage)
{ {
if (ximage->data != NULL) Xfree((char *)ximage->data); Xfree(ximage->data);
if (ximage->obdata != NULL) Xfree((char *)ximage->obdata); Xfree(ximage->obdata);
Xfree((char *)ximage); Xfree(ximage);
return 1; return 1;
} }
...@@ -542,8 +543,7 @@ static unsigned long _XGetPixel32 ( ...@@ -542,8 +543,7 @@ static unsigned long _XGetPixel32 (
[y * ximage->bytes_per_line + (x << 2)]; [y * ximage->bytes_per_line + (x << 2)];
if (*((const char *)&byteorderpixel) == ximage->byte_order) if (*((const char *)&byteorderpixel) == ximage->byte_order)
pixel = *((CARD32 *)addr); pixel = *((CARD32 *)addr);
else else if (ximage->byte_order == MSBFirst)
if (ximage->byte_order == MSBFirst)
pixel = ((unsigned long)addr[0] << 24 | pixel = ((unsigned long)addr[0] << 24 |
(unsigned long)addr[1] << 16 | (unsigned long)addr[1] << 16 |
(unsigned long)addr[2] << 8 | (unsigned long)addr[2] << 8 |
...@@ -731,8 +731,7 @@ static int _XPutPixel32 ( ...@@ -731,8 +731,7 @@ static int _XPutPixel32 (
[y * ximage->bytes_per_line + (x << 2)]; [y * ximage->bytes_per_line + (x << 2)];
if (*((const char *)&byteorderpixel) == ximage->byte_order) if (*((const char *)&byteorderpixel) == ximage->byte_order)
*((CARD32 *)addr) = pixel; *((CARD32 *)addr) = pixel;
else else if (ximage->byte_order == MSBFirst) {
if (ximage->byte_order == MSBFirst) {
addr[0] = pixel >> 24; addr[0] = pixel >> 24;
addr[1] = pixel >> 16; addr[1] = pixel >> 16;
addr[2] = pixel >> 8; addr[2] = pixel >> 8;
...@@ -843,7 +842,7 @@ static XImage *_XSubImage ( ...@@ -843,7 +842,7 @@ static XImage *_XSubImage (
register unsigned long pixel; register unsigned long pixel;
char *data; char *data;
if ((subimage = (XImage *) Xcalloc (1, sizeof (XImage))) == NULL) if ((subimage = Xcalloc (1, sizeof (XImage))) == NULL)
return (XImage *) NULL; return (XImage *) NULL;
subimage->width = width; subimage->width = width;
subimage->height = height; subimage->height = height;
...@@ -869,8 +868,8 @@ static XImage *_XSubImage ( ...@@ -869,8 +868,8 @@ static XImage *_XSubImage (
_XInitImageFuncPtrs (subimage); _XInitImageFuncPtrs (subimage);
dsize = subimage->bytes_per_line * height; dsize = subimage->bytes_per_line * height;
if (subimage->format == XYPixmap) dsize = dsize * subimage->depth; if (subimage->format == XYPixmap) dsize = dsize * subimage->depth;
if (((data = Xcalloc (1, (unsigned) dsize)) == NULL) && (dsize > 0)) { if (((data = Xcalloc (1, dsize)) == NULL) && (dsize > 0)) {
Xfree((char *) subimage); Xfree(subimage);
return (XImage *) NULL; return (XImage *) NULL;
} }
subimage->data = data; subimage->data = data;
......
...@@ -159,8 +159,7 @@ EXTRA_LIBRARIES = /**/ ...@@ -159,8 +159,7 @@ EXTRA_LIBRARIES = /**/
XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
EDB_DEFINES = -DERRORDB=\"$(USRDATADIR)/XErrorDB\" EDB_DEFINES = -DERRORDB=\"$(USRDATADIR)/XErrorDB\"
KDB_DEFINES = -DKEYSYMDB=\"$(USRDATADIR)/XKeysymDB\" CMS_DEFINES = -DXCMSDB=\"$(USRDATADIR)/Xcms.txt\" -DXCMSDIR=\"$(USRDATADIR)\"
CMS_DEFINES = -DXCMSDB=\"$(USRDATADIR)/Xcms.txt\"
#if HasSnprintf #if HasSnprintf
MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11 MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
#endif #endif
...@@ -925,10 +924,7 @@ STATICI18NSTATICSRCS = \ ...@@ -925,10 +924,7 @@ STATICI18NSTATICSRCS = \
imTrX.c \ imTrX.c \
imTransR.c \ imTransR.c \
imTrans.c \ imTrans.c \
lcEuc.c \
lcGenConv.c \ lcGenConv.c \
lcJis.c \
lcSjis.c \
lcUTF8Load.c \ lcUTF8Load.c \
omDefault.c \ omDefault.c \
omGeneric.c \ omGeneric.c \
...@@ -999,10 +995,7 @@ STATICI18NSTATICOBJS = \ ...@@ -999,10 +995,7 @@ STATICI18NSTATICOBJS = \
imTrX.o \ imTrX.o \
imTransR.o \ imTransR.o \
imTrans.o \ imTrans.o \
lcEuc.o \
lcGenConv.o \ lcGenConv.o \
lcJis.o \
lcSjis.o \
lcUTF8Load.o \ lcUTF8Load.o \
omDefault.o \ omDefault.o \
omGeneric.o \ omGeneric.o \
...@@ -1063,7 +1056,6 @@ EXTRASHAREDOBJS = $(STATICLCOBJS) ...@@ -1063,7 +1056,6 @@ EXTRASHAREDOBJS = $(STATICLCOBJS)
#include <Library.tmpl> #include <Library.tmpl>
SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES)) SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES))
SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS)) SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS))
SpecialCLibObjectRule(x11_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES)) SpecialCLibObjectRule(x11_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES))
SpecialCLibObjectRule(xim_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES)) SpecialCLibObjectRule(xim_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES))
...@@ -1100,7 +1092,6 @@ SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_D ...@@ -1100,7 +1092,6 @@ SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_D
InstallNonExecFile(Xcms.txt,$(LIBDIR)) InstallNonExecFile(Xcms.txt,$(LIBDIR))
#endif #endif
InstallNonExecFile(XErrorDB,$(LIBDIR)) InstallNonExecFile(XErrorDB,$(LIBDIR))
InstallNonExecFile(XKeysymDB,$(LIBDIR))
InstallLintLibrary(X11,$(LINTLIBDIR)) InstallLintLibrary(X11,$(LINTLIBDIR))
#ifdef QNX4Architecture #ifdef QNX4Architecture
......
...@@ -49,15 +49,14 @@ XExtCodes *XInitExtension ( ...@@ -49,15 +49,14 @@ XExtCodes *XInitExtension (
&codes.first_error)) return (NULL); &codes.first_error)) return (NULL);
LockDisplay (dpy); LockDisplay (dpy);
if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) || if (! (ext = Xcalloc (1, sizeof (_XExtension))) ||
! (ext->name = Xmalloc((unsigned) strlen(name) + 1))) { ! (ext->name = strdup(name))) {
if (ext) Xfree((char *) ext); Xfree(ext);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XExtCodes *) NULL; return (XExtCodes *) NULL;
} }
codes.extension = dpy->ext_number++; codes.extension = dpy->ext_number++;
ext->codes = codes; ext->codes = codes;
(void) strcpy(ext->name, name);
/* chain it onto the display list */ /* chain it onto the display list */
ext->next = dpy->ext_procs; ext->next = dpy->ext_procs;
...@@ -72,7 +71,7 @@ XExtCodes *XAddExtension (Display *dpy) ...@@ -72,7 +71,7 @@ XExtCodes *XAddExtension (Display *dpy)
register _XExtension *ext; register _XExtension *ext;
LockDisplay (dpy); LockDisplay (dpy);
if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) { if (! (ext = Xcalloc (1, sizeof (_XExtension)))) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XExtCodes *) NULL; return (XExtCodes *) NULL;
} }
......
...@@ -47,9 +47,9 @@ _XFreeAtomTable(Display *dpy) ...@@ -47,9 +47,9 @@ _XFreeAtomTable(Display *dpy)
table = dpy->atoms->table; table = dpy->atoms->table;
for (i = TABLESIZE; --i >= 0; ) { for (i = TABLESIZE; --i >= 0; ) {
if ((e = *table++) && (e != RESERVED)) if ((e = *table++) && (e != RESERVED))
Xfree((char *)e); Xfree(e);
} }
Xfree((char *)dpy->atoms); Xfree(dpy->atoms);
} }
} }
...@@ -72,7 +72,7 @@ Atom _XInternAtom( ...@@ -72,7 +72,7 @@ Atom _XInternAtom(
/* look in the cache first */ /* look in the cache first */
if (!(atoms = dpy->atoms)) { if (!(atoms = dpy->atoms)) {
dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); dpy->atoms = atoms = Xcalloc(1, sizeof(AtomTable));
dpy->free_funcs->atoms = _XFreeAtomTable; dpy->free_funcs->atoms = _XFreeAtomTable;
} }
sig = 0; sig = 0;
...@@ -127,7 +127,7 @@ _XUpdateAtomCache( ...@@ -127,7 +127,7 @@ _XUpdateAtomCache(
if (!dpy->atoms) { if (!dpy->atoms) {
if (idx < 0) { if (idx < 0) {
dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); dpy->atoms = Xcalloc(1, sizeof(AtomTable));
dpy->free_funcs->atoms = _XFreeAtomTable; dpy->free_funcs->atoms = _XFreeAtomTable;
} }
if (!dpy->atoms) if (!dpy->atoms)
...@@ -147,13 +147,13 @@ _XUpdateAtomCache( ...@@ -147,13 +147,13 @@ _XUpdateAtomCache(
} }
} }
} }
e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1); e = Xmalloc(sizeof(EntryRec) + n + 1);
if (e) { if (e) {
e->sig = sig; e->sig = sig;
e->atom = atom; e->atom = atom;
strcpy(EntryName(e), name); strcpy(EntryName(e), name);
if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED)) if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED))
Xfree((char *)oe); Xfree(oe);
dpy->atoms->table[idx] = e; dpy->atoms->table[idx] = e;
} }
} }
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
#ifndef _KEY_H_ #ifndef _KEY_H_
#define _KEY_H_ #define _KEY_H_
#include <nx-X11/Xlib.h>
#include <nx-X11/Xresource.h>
#ifndef NEEDKTABLE #ifndef NEEDKTABLE
extern const unsigned char _XkeyTable[]; extern const unsigned char _XkeyTable[];
#endif #endif
......
...@@ -44,14 +44,10 @@ in this Software without prior written authorization from The Open Group. ...@@ -44,14 +44,10 @@ in this Software without prior written authorization from The Open Group.
#define XK_CAUCASUS #define XK_CAUCASUS
#define XK_VIETNAMESE #define XK_VIETNAMESE
#define XK_XKB_KEYS #define XK_XKB_KEYS
#define XK_SINHALA
#include <nx-X11/keysymdef.h> #include <nx-X11/keysymdef.h>
#include <stdio.h> #include <stdio.h>
#ifdef USE_OWN_COMPOSE
#include "imComp.h"
#endif
#include "Xresource.h" #include "Xresource.h"
#include "Key.h" #include "Key.h"
...@@ -238,7 +234,7 @@ XRefreshKeyboardMapping(register XMappingEvent *event) ...@@ -238,7 +234,7 @@ XRefreshKeyboardMapping(register XMappingEvent *event)
*/ */
LockDisplay(event->display); LockDisplay(event->display);
if (event->display->keysyms) { if (event->display->keysyms) {
Xfree ((char *)event->display->keysyms); Xfree (event->display->keysyms);
event->display->keysyms = NULL; event->display->keysyms = NULL;
} }
UnlockDisplay(event->display); UnlockDisplay(event->display);
...@@ -275,12 +271,13 @@ _XKeyInitialize( ...@@ -275,12 +271,13 @@ _XKeyInitialize(
if (! keysyms) return 0; if (! keysyms) return 0;
LockDisplay(dpy); LockDisplay(dpy);
if (dpy->keysyms)
Xfree ((char *)dpy->keysyms); Xfree (dpy->keysyms);
dpy->keysyms = keysyms; dpy->keysyms = keysyms;
dpy->keysyms_per_keycode = per; dpy->keysyms_per_keycode = per;
if (dpy->modifiermap) if (dpy->modifiermap)
ResetModMap(dpy); ResetModMap(dpy);
UnlockDisplay(dpy); UnlockDisplay(dpy);
} }
if (!dpy->modifiermap) if (!dpy->modifiermap)
...@@ -890,73 +887,6 @@ XLookupString ( ...@@ -890,73 +887,6 @@ XLookupString (
&modifiers, &symbol)) &modifiers, &symbol))
return 0; return 0;
#ifdef USE_OWN_COMPOSE
if ( status ) {
static int been_here= 0;
if ( !been_here ) {
XimCompInitTables();
been_here = 1;
}
if ( !XimCompLegalStatus(status) ) {
status->compose_ptr = NULL;
status->chars_matched = 0;
}
if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
XimCompIsComposeKey(symbol,event->keycode,status) ) {
XimCompRtrn rtrn;
switch (XimCompProcessSym(status,symbol,&rtrn)) {
case XIM_COMP_IGNORE:
break;
case XIM_COMP_IN_PROGRESS:
if ( keysym!=NULL )
*keysym = NoSymbol;
return 0;
case XIM_COMP_FAIL:
{
int n = 0, len= 0;
for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
if ( nbytes-len > 0 ) {
len+= _XTranslateKeySym(event->display,rtrn.sym[n],
event->state,
buffer+len,nbytes-len);
}
}
if ( keysym!=NULL ) {
if ( n==1 ) *keysym = rtrn.sym[0];
else *keysym = NoSymbol;
}
return len;
}
case XIM_COMP_SUCCEED:
{
int len,n = 0;
symbol = rtrn.matchSym;
if ( keysym!=NULL ) *keysym = symbol;
if ( rtrn.str[0]!='\0' ) {
strncpy(buffer,rtrn.str,nbytes-1);
buffer[nbytes-1]= '\0';
len = strlen(buffer);
}
else {
len = _XTranslateKeySym(event->display,symbol,
event->state,
buffer,nbytes);
}
for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
if ( nbytes-len > 0 ) {
len+= _XTranslateKeySym(event->display,rtrn.sym[n],
event->state,
buffer+len,nbytes-len);
}
}
return len;
}
}
}
}
#endif
if (keysym) if (keysym)
*keysym = symbol; *keysym = symbol;
/* arguable whether to use (event->state & ~modifiers) here */ /* arguable whether to use (event->state & ~modifiers) here */
...@@ -973,8 +903,8 @@ _XFreeKeyBindings( ...@@ -973,8 +903,8 @@ _XFreeKeyBindings(
for (p = dpy->key_bindings; p; p = np) { for (p = dpy->key_bindings; p; p = np) {
np = p->next; np = p->next;
Xfree(p->string); Xfree(p->string);
Xfree((char *)p->modifiers); Xfree(p->modifiers);
Xfree((char *)p); Xfree(p);
} }
} }
...@@ -996,15 +926,13 @@ XRebindKeysym ( ...@@ -996,15 +926,13 @@ XRebindKeysym (
tmp = dpy->key_bindings; tmp = dpy->key_bindings;
nb = sizeof(KeySym) * nm; nb = sizeof(KeySym) * nm;
if ((! (p = (struct _XKeytrans *) Xmalloc( sizeof(struct _XKeytrans)))) || if ((! (p = Xcalloc( 1, sizeof(struct _XKeytrans)))) ||
((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) && ((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) ||
(nbytes > 0)) || ((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) {
((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) &&
(nb > 0))) {
if (p) { if (p) {
if (p->string) Xfree(p->string); Xfree(p->string);
if (p->modifiers) Xfree((char *) p->modifiers); Xfree(p->modifiers);
Xfree((char *) p); Xfree(p);
} }
UnlockDisplay(dpy); UnlockDisplay(dpy);
return 0; return 0;
...@@ -1013,7 +941,7 @@ XRebindKeysym ( ...@@ -1013,7 +941,7 @@ XRebindKeysym (
dpy->key_bindings = p; dpy->key_bindings = p;
dpy->free_funcs->key_bindings = _XFreeKeyBindings; dpy->free_funcs->key_bindings = _XFreeKeyBindings;
p->next = tmp; /* chain onto list */ p->next = tmp; /* chain onto list */
memcpy (p->string, (char *) str, nbytes); memcpy (p->string, str, nbytes);
p->len = nbytes; p->len = nbytes;
memcpy ((char *) p->modifiers, (char *) mlist, nb); memcpy ((char *) p->modifiers, (char *) mlist, nb);
p->key = keysym; p->key = keysym;
......
...@@ -70,11 +70,6 @@ SameValue( ...@@ -70,11 +70,6 @@ SameValue(
char *XKeysymToString(KeySym ks) char *XKeysymToString(KeySym ks)
{ {
register int i, n;
int h;
register int idx;
const unsigned char *entry;
unsigned char val1, val2, val3, val4;
XrmDatabase keysymdb; XrmDatabase keysymdb;
if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0) if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
...@@ -83,16 +78,17 @@ char *XKeysymToString(KeySym ks) ...@@ -83,16 +78,17 @@ char *XKeysymToString(KeySym ks)
ks = 0; ks = 0;
if (ks <= 0x1fffffff) if (ks <= 0x1fffffff)
{ {
val1 = ks >> 24; unsigned char val1 = ks >> 24;
val2 = (ks >> 16) & 0xff; unsigned char val2 = (ks >> 16) & 0xff;
val3 = (ks >> 8) & 0xff; unsigned char val3 = (ks >> 8) & 0xff;
val4 = ks & 0xff; unsigned char val4 = ks & 0xff;
i = ks % VTABLESIZE; int i = ks % VTABLESIZE;
h = i + 1; int h = i + 1;
n = VMAXHASH; int n = VMAXHASH;
int idx;
while ((idx = hashKeysym[i])) while ((idx = hashKeysym[i]))
{ {
entry = &_XkeyTable[idx]; const unsigned char *entry = &_XkeyTable[idx];
if ((entry[0] == val1) && (entry[1] == val2) && if ((entry[0] == val1) && (entry[1] == val2) &&
(entry[2] == val3) && (entry[3] == val4)) (entry[2] == val3) && (entry[3] == val4))
return ((char *)entry + 4); return ((char *)entry + 4);
...@@ -111,7 +107,7 @@ char *XKeysymToString(KeySym ks) ...@@ -111,7 +107,7 @@ char *XKeysymToString(KeySym ks)
XrmQuark empty = NULLQUARK; XrmQuark empty = NULLQUARK;
GRNData data; GRNData data;
sprintf(buf, "%lX", ks); snprintf(buf, sizeof(buf), "%lX", ks);
resval.addr = (XPointer)buf; resval.addr = (XPointer)buf;
resval.size = strlen(buf) + 1; resval.size = strlen(buf) + 1;
data.name = (char *)NULL; data.name = (char *)NULL;
...@@ -136,7 +132,7 @@ char *XKeysymToString(KeySym ks) ...@@ -136,7 +132,7 @@ char *XKeysymToString(KeySym ks)
i--; i--;
s[i--] = '\0'; s[i--] = '\0';
for (; i; i--){ for (; i; i--){
val1 = val & 0xf; unsigned char val1 = val & 0xf;
val >>= 4; val >>= 4;
if (val1 < 10) if (val1 < 10)
s[i] = '0'+ val1; s[i] = '0'+ val1;
......
...@@ -511,7 +511,7 @@ LINEAR_RGB_InitSCCData( ...@@ -511,7 +511,7 @@ LINEAR_RGB_InitSCCData(
*pValue++ = (long)_XcmsGetElement(format_return, &pChar, *pValue++ = (long)_XcmsGetElement(format_return, &pChar,
&nitems) / (XcmsFloat)XDCCC_NUMBER; &nitems) / (XcmsFloat)XDCCC_NUMBER;
} }
Xfree ((char *)property_return); Xfree (property_return);
pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X = pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
pScreenData->RGBtoXYZmatrix[0][0] + pScreenData->RGBtoXYZmatrix[0][0] +
pScreenData->RGBtoXYZmatrix[0][1] + pScreenData->RGBtoXYZmatrix[0][1] +
...@@ -573,7 +573,6 @@ LINEAR_RGB_InitSCCData( ...@@ -573,7 +573,6 @@ LINEAR_RGB_InitSCCData(
if (CorrectAtom == None || if (CorrectAtom == None ||
!_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), CorrectAtom, !_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), CorrectAtom,
&format_return, &nitems, &nbytes_return, &property_return)) { &format_return, &nitems, &nbytes_return, &property_return)) {
Xfree ((char *)property_return);
goto FreeSCCData; goto FreeSCCData;
} }
...@@ -595,8 +594,7 @@ LINEAR_RGB_InitSCCData( ...@@ -595,8 +594,7 @@ LINEAR_RGB_InitSCCData(
* intensity2 * intensity2
*/ */
if (nitems < 9) { if (nitems < 9) {
Xfree ((char *)property_return); goto Free_property_return;
goto FreeSCCData;
} }
count = 3; count = 3;
break; break;
...@@ -612,8 +610,7 @@ LINEAR_RGB_InitSCCData( ...@@ -612,8 +610,7 @@ LINEAR_RGB_InitSCCData(
* intensity2 * intensity2
*/ */
if (nitems < 7) { if (nitems < 7) {
Xfree ((char *)property_return); goto Free_property_return;
goto FreeSCCData;
} }
count = 1; count = 1;
break; break;
...@@ -628,14 +625,12 @@ LINEAR_RGB_InitSCCData( ...@@ -628,14 +625,12 @@ LINEAR_RGB_InitSCCData(
* intensity2 * intensity2
*/ */
if (nitems < 6) { if (nitems < 6) {
Xfree ((char *)property_return); goto Free_property_return;
goto FreeSCCData;
} }
count = 0; count = 0;
break; break;
default: default:
Xfree ((char *)property_return); goto Free_property_return;
goto FreeSCCData;
} }
/* /*
...@@ -658,7 +653,7 @@ LINEAR_RGB_InitSCCData( ...@@ -658,7 +653,7 @@ LINEAR_RGB_InitSCCData(
*/ */
if (!(pScreenData = (LINEAR_RGB_SCCData *) if (!(pScreenData = (LINEAR_RGB_SCCData *)
Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) { Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
return(XcmsFailure); goto Free_property_return;
} }
/* copy matrices */ /* copy matrices */
memcpy((char *)pScreenData, (char *)pScreenDefaultData, memcpy((char *)pScreenData, (char *)pScreenDefaultData,
...@@ -667,8 +662,8 @@ LINEAR_RGB_InitSCCData( ...@@ -667,8 +662,8 @@ LINEAR_RGB_InitSCCData(
/* Create, initialize, and add map */ /* Create, initialize, and add map */
if (!(pNewMap = (XcmsIntensityMap *) if (!(pNewMap = (XcmsIntensityMap *)
Xcalloc (1, sizeof(XcmsIntensityMap)))) { Xcalloc (1, sizeof(XcmsIntensityMap)))) {
Xfree((char *)pScreenData); Xfree(pScreenData);
return(XcmsFailure); goto Free_property_return;
} }
pNewMap->visualID = visualID; pNewMap->visualID = visualID;
pNewMap->screenData = (XPointer)pScreenData; pNewMap->screenData = (XPointer)pScreenData;
...@@ -687,7 +682,7 @@ LINEAR_RGB_InitSCCData( ...@@ -687,7 +682,7 @@ LINEAR_RGB_InitSCCData(
/* Red Intensity Table */ /* Red Intensity Table */
if (!(pScreenData->pRedTbl = (IntensityTbl *) if (!(pScreenData->pRedTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) { Xcalloc (1, sizeof(IntensityTbl)))) {
goto FreeSCCData; goto Free_property_return;
} }
if (_XcmsGetTableType0(pScreenData->pRedTbl, format_return, &pChar, if (_XcmsGetTableType0(pScreenData->pRedTbl, format_return, &pChar,
&nitems) == XcmsFailure) { &nitems) == XcmsFailure) {
...@@ -724,7 +719,7 @@ LINEAR_RGB_InitSCCData( ...@@ -724,7 +719,7 @@ LINEAR_RGB_InitSCCData(
/* Red Intensity Table */ /* Red Intensity Table */
if (!(pScreenData->pRedTbl = (IntensityTbl *) if (!(pScreenData->pRedTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) { Xcalloc (1, sizeof(IntensityTbl)))) {
goto FreeSCCData; goto Free_property_return;
} }
if (_XcmsGetTableType1(pScreenData->pRedTbl, format_return, &pChar, if (_XcmsGetTableType1(pScreenData->pRedTbl, format_return, &pChar,
&nitems) == XcmsFailure) { &nitems) == XcmsFailure) {
...@@ -753,7 +748,7 @@ LINEAR_RGB_InitSCCData( ...@@ -753,7 +748,7 @@ LINEAR_RGB_InitSCCData(
/* Blue Intensity Table */ /* Blue Intensity Table */
if (!(pScreenData->pBlueTbl = (IntensityTbl *) if (!(pScreenData->pBlueTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) { Xcalloc (1, sizeof(IntensityTbl)))) {
goto FreeBlueTblElements; goto FreeGreenTblElements;
} }
if (_XcmsGetTableType1(pScreenData->pBlueTbl, format_return, &pChar, if (_XcmsGetTableType1(pScreenData->pBlueTbl, format_return, &pChar,
&nitems) == XcmsFailure) { &nitems) == XcmsFailure) {
...@@ -761,8 +756,7 @@ LINEAR_RGB_InitSCCData( ...@@ -761,8 +756,7 @@ LINEAR_RGB_InitSCCData(
} }
} }
} else { } else {
Xfree ((char *)property_return); goto Free_property_return;
goto FreeSCCData;
} }
#ifdef ALLDEBUG #ifdef ALLDEBUG
...@@ -788,7 +782,7 @@ LINEAR_RGB_InitSCCData( ...@@ -788,7 +782,7 @@ LINEAR_RGB_InitSCCData(
#endif /* ALLDEBUG */ #endif /* ALLDEBUG */
} }
Xfree ((char *)property_return); Xfree (property_return);
/* Free the old memory and use the new structure created. */ /* Free the old memory and use the new structure created. */
LINEAR_RGB_FreeSCCData(pPerScrnInfo->screenData); LINEAR_RGB_FreeSCCData(pPerScrnInfo->screenData);
...@@ -802,25 +796,28 @@ LINEAR_RGB_InitSCCData( ...@@ -802,25 +796,28 @@ LINEAR_RGB_InitSCCData(
return(XcmsSuccess); return(XcmsSuccess);
FreeBlueTblElements: FreeBlueTblElements:
Xfree((char *)pScreenData->pBlueTbl->pBase); Xfree(pScreenData->pBlueTbl->pBase);
FreeBlueTbl: FreeBlueTbl:
Xfree((char *)pScreenData->pBlueTbl); Xfree(pScreenData->pBlueTbl);
FreeGreenTblElements: FreeGreenTblElements:
Xfree((char *)pScreenData->pBlueTbl->pBase); Xfree(pScreenData->pGreenTbl->pBase);
FreeGreenTbl: FreeGreenTbl:
Xfree((char *)pScreenData->pGreenTbl); Xfree(pScreenData->pGreenTbl);
FreeRedTblElements: FreeRedTblElements:
Xfree((char *)pScreenData->pRedTbl->pBase); Xfree(pScreenData->pRedTbl->pBase);
FreeRedTbl: FreeRedTbl:
Xfree((char *)pScreenData->pRedTbl); Xfree(pScreenData->pRedTbl);
Free_property_return:
Xfree (property_return);
FreeSCCData: FreeSCCData:
Xfree((char *)pScreenData); Xfree(pScreenDefaultData);
pPerScrnInfo->state = XcmsInitNone; pPerScrnInfo->state = XcmsInitNone;
return(XcmsFailure); return(XcmsFailure);
} }
...@@ -852,30 +849,30 @@ LINEAR_RGB_FreeSCCData( ...@@ -852,30 +849,30 @@ LINEAR_RGB_FreeSCCData(
if (pScreenData->pRedTbl->pBase != if (pScreenData->pRedTbl->pBase !=
pScreenData->pGreenTbl->pBase) { pScreenData->pGreenTbl->pBase) {
if (pScreenData->pGreenTbl->pBase) { if (pScreenData->pGreenTbl->pBase) {
Xfree ((char *)pScreenData->pGreenTbl->pBase); Xfree (pScreenData->pGreenTbl->pBase);
} }
} }
if (pScreenData->pGreenTbl != pScreenData->pRedTbl) { if (pScreenData->pGreenTbl != pScreenData->pRedTbl) {
Xfree ((char *)pScreenData->pGreenTbl); Xfree (pScreenData->pGreenTbl);
} }
} }
if (pScreenData->pBlueTbl) { if (pScreenData->pBlueTbl) {
if (pScreenData->pRedTbl->pBase != if (pScreenData->pRedTbl->pBase !=
pScreenData->pBlueTbl->pBase) { pScreenData->pBlueTbl->pBase) {
if (pScreenData->pBlueTbl->pBase) { if (pScreenData->pBlueTbl->pBase) {
Xfree ((char *)pScreenData->pBlueTbl->pBase); Xfree (pScreenData->pBlueTbl->pBase);
} }
} }
if (pScreenData->pBlueTbl != pScreenData->pRedTbl) { if (pScreenData->pBlueTbl != pScreenData->pRedTbl) {
Xfree ((char *)pScreenData->pBlueTbl); Xfree (pScreenData->pBlueTbl);
} }
} }
if (pScreenData->pRedTbl->pBase) { if (pScreenData->pRedTbl->pBase) {
Xfree ((char *)pScreenData->pRedTbl->pBase); Xfree (pScreenData->pRedTbl->pBase);
} }
Xfree ((char *)pScreenData->pRedTbl); Xfree (pScreenData->pRedTbl);
} }
Xfree ((char *)pScreenData); Xfree (pScreenData);
} }
} }
...@@ -969,7 +966,7 @@ _XcmsGetTableType1( ...@@ -969,7 +966,7 @@ _XcmsGetTableType1(
* *
*/ */
{ {
int count; unsigned int count;
unsigned int max_index; unsigned int max_index;
IntensityRec *pIRec; IntensityRec *pIRec;
...@@ -1408,13 +1405,13 @@ XcmsLRGB_RGBi_ParseString( ...@@ -1408,13 +1405,13 @@ XcmsLRGB_RGBi_ParseString(
* 0 if failed, non-zero otherwise. * 0 if failed, non-zero otherwise.
*/ */
{ {
int n; size_t n;
char *pchar; char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) { if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure); return(XcmsFailure);
} }
n = (int)(pchar - spec); n = (size_t)(pchar - spec);
/* /*
* Check for proper prefix. * Check for proper prefix.
......
...@@ -251,7 +251,7 @@ XcmsCIELabToCIEXYZ( ...@@ -251,7 +251,7 @@ XcmsCIELabToCIEXYZ(
XcmsCIEXYZ XYZ_return; XcmsCIEXYZ XYZ_return;
XcmsFloat tmpFloat, tmpL; XcmsFloat tmpFloat, tmpL;
XcmsColor whitePt; XcmsColor whitePt;
int i; unsigned int i;
XcmsColor *pColor = pColors_in_out; XcmsColor *pColor = pColors_in_out;
/* /*
...@@ -354,7 +354,7 @@ XcmsCIEXYZToCIELab( ...@@ -354,7 +354,7 @@ XcmsCIEXYZToCIELab(
XcmsCIELab Lab_return; XcmsCIELab Lab_return;
XcmsFloat fX_Xn, fY_Yn, fZ_Zn; XcmsFloat fX_Xn, fY_Yn, fZ_Zn;
XcmsColor whitePt; XcmsColor whitePt;
int i; unsigned int i;
XcmsColor *pColor = pColors_in_out; XcmsColor *pColor = pColors_in_out;
/* /*
......
...@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group. ...@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group.
*/ */
/* /*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Copyright 2004 Oracle and/or its affiliates. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
...@@ -154,3 +154,4 @@ XHostAddress *XListHosts ( ...@@ -154,3 +154,4 @@ XHostAddress *XListHosts (
...@@ -42,7 +42,7 @@ char **XListExtensions( ...@@ -42,7 +42,7 @@ char **XListExtensions(
register unsigned i; register unsigned i;
register int length; register int length;
register xReq *req; register xReq *req;
unsigned long rlen; unsigned long rlen = 0;
LockDisplay(dpy); LockDisplay(dpy);
GetEmptyReq (ListExtensions, req); GetEmptyReq (ListExtensions, req);
...@@ -55,15 +55,15 @@ char **XListExtensions( ...@@ -55,15 +55,15 @@ char **XListExtensions(
if (rep.nExtensions) { if (rep.nExtensions) {
list = Xmalloc (rep.nExtensions * sizeof (char *)); list = Xmalloc (rep.nExtensions * sizeof (char *));
if (rep.length < (LONG_MAX >> 2)) { if (rep.length > 0 && rep.length < (INT_MAX >> 2)) {
rlen = rep.length << 2; rlen = rep.length << 2;
ch = Xmalloc (rlen + 1); ch = Xmalloc (rlen + 1);
/* +1 to leave room for last null-terminator */ /* +1 to leave room for last null-terminator */
} }
if ((!list) || (!ch)) { if ((!list) || (!ch)) {
if (list) Xfree((char *) list); Xfree(list);
if (ch) Xfree((char *) ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
...@@ -80,9 +80,13 @@ char **XListExtensions( ...@@ -80,9 +80,13 @@ char **XListExtensions(
if (ch + length < chend) { if (ch + length < chend) {
list[i] = ch+1; /* skip over length */ list[i] = ch+1; /* skip over length */
ch += length + 1; /* find next length ... */ ch += length + 1; /* find next length ... */
if (ch <= chend) {
length = *ch; length = *ch;
*ch = '\0'; /* and replace with null-termination */ *ch = '\0'; /* and replace with null-termination */
count++; count++;
} else {
list[i] = NULL;
}
} else } else
list[i] = NULL; list[i] = NULL;
} }
...@@ -99,7 +103,7 @@ XFreeExtensionList (char **list) ...@@ -99,7 +103,7 @@ XFreeExtensionList (char **list)
{ {
if (list != NULL) { if (list != NULL) {
Xfree (list[0]-1); Xfree (list[0]-1);
Xfree ((char *)list); Xfree (list);
} }
return 1; return 1;
} }
...@@ -251,7 +251,7 @@ XcmsCIELuvToCIEuvY( ...@@ -251,7 +251,7 @@ XcmsCIELuvToCIEuvY(
XcmsColor whitePt; XcmsColor whitePt;
XcmsCIEuvY uvY_return; XcmsCIEuvY uvY_return;
XcmsFloat tmpVal; XcmsFloat tmpVal;
register int i; unsigned int i;
/* /*
* Check arguments * Check arguments
...@@ -343,7 +343,7 @@ XcmsCIEuvYToCIELuv( ...@@ -343,7 +343,7 @@ XcmsCIEuvYToCIELuv(
XcmsColor whitePt; XcmsColor whitePt;
XcmsCIELuv Luv_return; XcmsCIELuv Luv_return;
XcmsFloat tmpVal; XcmsFloat tmpVal;
register int i; unsigned int i;
/* /*
* Check arguments * Check arguments
......
...@@ -30,6 +30,9 @@ in this Software without prior written authorization from The Open Group. ...@@ -30,6 +30,9 @@ in this Software without prior written authorization from The Open Group.
#include "Xlibint.h" #include "Xlibint.h"
#define XUTIL_DEFINE_FUNCTIONS #define XUTIL_DEFINE_FUNCTIONS
#include "Xutil.h" #include "Xutil.h"
#if USE_XCB
#include "Xxcbint.h"
#endif
/* /*
* This file makes full definitions of routines for each macro. * This file makes full definitions of routines for each macro.
...@@ -135,10 +138,28 @@ int XBitmapPad(Display *dpy) { return (BitmapPad(dpy)); } ...@@ -135,10 +138,28 @@ int XBitmapPad(Display *dpy) { return (BitmapPad(dpy)); }
int XImageByteOrder(Display *dpy) { return (ImageByteOrder(dpy)); } int XImageByteOrder(Display *dpy) { return (ImageByteOrder(dpy)); }
#if !USE_XCB
unsigned long XNextRequest(Display *dpy) unsigned long XNextRequest(Display *dpy)
{ {
return (NextRequest(dpy)); return (NextRequest(dpy));
} }
#else
/* XNextRequest() differs from the rest of the functions here because it is
* no longer a macro wrapper - when libX11 is being used mixed together
* with direct use of xcb, the next request field of the Display structure will
* not be updated. We can't fix the NextRequest() macro in any easy way,
* but we can at least make XNextRequest() do the right thing.
*/
unsigned long XNextRequest(Display *dpy)
{
unsigned long next_request;
LockDisplay(dpy);
next_request = _XNextRequest(dpy);
UnlockDisplay(dpy);
return next_request;
}
#endif
unsigned long XLastKnownRequestProcessed(Display *dpy) unsigned long XLastKnownRequestProcessed(Display *dpy)
{ {
......
...@@ -42,7 +42,8 @@ XGetModifierMapping(register Display *dpy) ...@@ -42,7 +42,8 @@ XGetModifierMapping(register Display *dpy)
GetEmptyReq(GetModifierMapping, req); GetEmptyReq(GetModifierMapping, req);
(void) _XReply (dpy, (xReply *)&rep, 0, xFalse); (void) _XReply (dpy, (xReply *)&rep, 0, xFalse);
if (rep.length < (LONG_MAX >> 2)) { if (rep.length < (INT_MAX >> 2) &&
(rep.length >> 1) == rep.numKeyPerModifier) {
nbytes = (unsigned long)rep.length << 2; nbytes = (unsigned long)rep.length << 2;
res = Xmalloc(sizeof (XModifierKeymap)); res = Xmalloc(sizeof (XModifierKeymap));
if (res) if (res)
...@@ -50,7 +51,7 @@ XGetModifierMapping(register Display *dpy) ...@@ -50,7 +51,7 @@ XGetModifierMapping(register Display *dpy)
} else } else
res = NULL; res = NULL;
if ((! res) || (! res->modifiermap)) { if ((! res) || (! res->modifiermap)) {
if (res) Xfree((char *) res); Xfree(res);
res = (XModifierKeymap *) NULL; res = (XModifierKeymap *) NULL;
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
} else { } else {
...@@ -65,9 +66,9 @@ XGetModifierMapping(register Display *dpy) ...@@ -65,9 +66,9 @@ XGetModifierMapping(register Display *dpy)
/* /*
* Returns: * Returns:
* 0 Success * MappingSuccess (0) Success
* 1 Busy - one or more old or new modifiers are down * MappingBusy (1) Busy - one or more old or new modifiers are down
* 2 Failed - one or more new modifiers unacceptable * MappingFailed (2) Failed - one or more new modifiers unacceptable
*/ */
int int
XSetModifierMapping( XSetModifierMapping(
...@@ -79,13 +80,11 @@ XSetModifierMapping( ...@@ -79,13 +80,11 @@ XSetModifierMapping(
int mapSize = modifier_map->max_keypermod << 3; /* 8 modifiers */ int mapSize = modifier_map->max_keypermod << 3; /* 8 modifiers */
LockDisplay(dpy); LockDisplay(dpy);
GetReqExtra(SetModifierMapping, mapSize, req); GetReq(SetModifierMapping, req);
req->length += mapSize >> 2;
req->numKeyPerModifier = modifier_map->max_keypermod; req->numKeyPerModifier = modifier_map->max_keypermod;
memcpy((char *) NEXTPTR(req,xSetModifierMappingReq), Data(dpy, modifier_map->modifiermap, mapSize);
(char *) modifier_map->modifiermap,
mapSize);
(void) _XReply(dpy, (xReply *) & rep, (void) _XReply(dpy, (xReply *) & rep,
(SIZEOF(xSetModifierMappingReply) - SIZEOF(xReply)) >> 2, xTrue); (SIZEOF(xSetModifierMappingReply) - SIZEOF(xReply)) >> 2, xTrue);
...@@ -97,14 +96,14 @@ XSetModifierMapping( ...@@ -97,14 +96,14 @@ XSetModifierMapping(
XModifierKeymap * XModifierKeymap *
XNewModifiermap(int keyspermodifier) XNewModifiermap(int keyspermodifier)
{ {
XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap))); XModifierKeymap *res = Xmalloc((sizeof (XModifierKeymap)));
if (res) { if (res) {
res->max_keypermod = keyspermodifier; res->max_keypermod = keyspermodifier;
res->modifiermap = (keyspermodifier > 0 ? res->modifiermap = (keyspermodifier > 0 ?
(KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier)) Xmalloc(8 * keyspermodifier)
: (KeyCode *) NULL); : (KeyCode *) NULL);
if (keyspermodifier && (res->modifiermap == NULL)) { if (keyspermodifier && (res->modifiermap == NULL)) {
Xfree((char *) res); Xfree(res);
return (XModifierKeymap *) NULL; return (XModifierKeymap *) NULL;
} }
} }
...@@ -116,9 +115,8 @@ int ...@@ -116,9 +115,8 @@ int
XFreeModifiermap(XModifierKeymap *map) XFreeModifiermap(XModifierKeymap *map)
{ {
if (map) { if (map) {
if (map->modifiermap) Xfree(map->modifiermap);
Xfree((char *) map->modifiermap); Xfree(map);
Xfree((char *) map);
} }
return 1; return 1;
} }
......
...@@ -73,12 +73,6 @@ extern void *_X11TransSocketProxyConnInfo(XtransConnInfo); ...@@ -73,12 +73,6 @@ extern void *_X11TransSocketProxyConnInfo(XtransConnInfo);
#endif #endif
#if !USE_XCB #if !USE_XCB
#ifdef X_NOT_POSIX
#define Size_t unsigned int
#else
#define Size_t size_t
#endif
#define bignamelen (sizeof(XBigReqExtensionName) - 1) #define bignamelen (sizeof(XBigReqExtensionName) - 1)
typedef struct { typedef struct {
...@@ -182,7 +176,7 @@ XOpenDisplay ( ...@@ -182,7 +176,7 @@ XOpenDisplay (
/* /*
* Attempt to allocate a display structure. Return NULL if allocation fails. * Attempt to allocate a display structure. Return NULL if allocation fails.
*/ */
if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) { if ((dpy = Xcalloc(1, sizeof(Display))) == NULL) {
return(NULL); return(NULL);
} }
...@@ -356,9 +350,7 @@ fallback_success: ...@@ -356,9 +350,7 @@ fallback_success:
dpy->qlen = 0; dpy->qlen = 0;
/* Set up free-function record */ /* Set up free-function record */
if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, if ((dpy->free_funcs = Xcalloc(1, sizeof(_XFreeFuncRec))) == NULL) {
sizeof(_XFreeFuncRec)))
== NULL) {
OutOfMemory (dpy, setup); OutOfMemory (dpy, setup);
return(NULL); return(NULL);
} }
...@@ -459,8 +451,8 @@ fallback_success: ...@@ -459,8 +451,8 @@ fallback_success:
if (prefix.lengthReason > setuplength) { if (prefix.lengthReason > setuplength) {
fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n"); fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
}else{ }else{
(void) fwrite (u.failure, (Size_t)sizeof(char), (void) fwrite (u.failure, (size_t)sizeof(char),
(Size_t)prefix.lengthReason, stderr); (size_t)prefix.lengthReason, stderr);
(void) fwrite ("\r\n", sizeof(char), 2, stderr); (void) fwrite ("\r\n", sizeof(char), 2, stderr);
} }
...@@ -523,7 +515,7 @@ fallback_success: ...@@ -523,7 +515,7 @@ fallback_success:
return (NULL); return (NULL);
} }
dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1)); dpy->vendor = Xmalloc(u.setup->nbytesVendor + 1);
if (dpy->vendor == NULL) { if (dpy->vendor == NULL) {
OutOfMemory(dpy, setup); OutOfMemory(dpy, setup);
return (NULL); return (NULL);
...@@ -713,6 +705,9 @@ fallback_success: ...@@ -713,6 +705,9 @@ fallback_success:
#endif /* !USE_XCB */ #endif /* !USE_XCB */
#if USE_XCB #if USE_XCB
/*
* get availability of large requests
*/
dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcb->connection); dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcb->connection);
if(dpy->bigreq_size <= dpy->max_request_size) if(dpy->bigreq_size <= dpy->max_request_size)
dpy->bigreq_size = 0; dpy->bigreq_size = 0;
...@@ -740,7 +735,6 @@ fallback_success: ...@@ -740,7 +735,6 @@ fallback_success:
(void) XSynchronize(dpy, _Xdebug); (void) XSynchronize(dpy, _Xdebug);
/* /*
* get availability of large requests, and
* get the resource manager database off the root window. * get the resource manager database off the root window.
*/ */
LockDisplay(dpy); LockDisplay(dpy);
...@@ -870,9 +864,8 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -870,9 +864,8 @@ void _XFreeDisplayStructure(Display *dpy)
while (dpy->ext_procs) { while (dpy->ext_procs) {
_XExtension *ext = dpy->ext_procs; _XExtension *ext = dpy->ext_procs;
dpy->ext_procs = ext->next; dpy->ext_procs = ext->next;
if (ext->name)
Xfree (ext->name); Xfree (ext->name);
Xfree ((char *)ext); Xfree (ext);
} }
if (dpy->im_filters) if (dpy->im_filters)
(*dpy->free_funcs->im_filters)(dpy); (*dpy->free_funcs->im_filters)(dpy);
...@@ -914,17 +907,17 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -914,17 +907,17 @@ void _XFreeDisplayStructure(Display *dpy)
for (k = 0; k < dp->nvisuals; k++) for (k = 0; k < dp->nvisuals; k++)
_XFreeExtData (dp->visuals[k].ext_data); _XFreeExtData (dp->visuals[k].ext_data);
Xfree ((char *) dp->visuals); Xfree (dp->visuals);
} }
} }
Xfree ((char *) sp->depths); Xfree (sp->depths);
} }
_XFreeExtData (sp->ext_data); _XFreeExtData (sp->ext_data);
} }
Xfree ((char *)dpy->screens); Xfree (dpy->screens);
} }
if (dpy->pixmap_format) { if (dpy->pixmap_format) {
...@@ -932,27 +925,20 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -932,27 +925,20 @@ void _XFreeDisplayStructure(Display *dpy)
for (i = 0; i < dpy->nformats; i++) for (i = 0; i < dpy->nformats; i++)
_XFreeExtData (dpy->pixmap_format[i].ext_data); _XFreeExtData (dpy->pixmap_format[i].ext_data);
Xfree ((char *)dpy->pixmap_format); Xfree (dpy->pixmap_format);
} }
if (dpy->display_name) free(dpy->display_name);
Xfree (dpy->display_name);
if (dpy->vendor)
Xfree (dpy->vendor);
if (dpy->buffer) Xfree (dpy->vendor);
Xfree (dpy->buffer); Xfree (dpy->buffer);
if (dpy->keysyms) Xfree (dpy->keysyms);
Xfree ((char *) dpy->keysyms);
if (dpy->xdefaults)
Xfree (dpy->xdefaults); Xfree (dpy->xdefaults);
if (dpy->error_vec) Xfree (dpy->error_vec);
Xfree ((char *)dpy->error_vec);
_XFreeExtData (dpy->ext_data); _XFreeExtData (dpy->ext_data);
if (dpy->free_funcs)
Xfree ((char *)dpy->free_funcs); Xfree (dpy->free_funcs);
if (dpy->scratch_buffer)
Xfree (dpy->scratch_buffer); Xfree (dpy->scratch_buffer);
FreeDisplayLock(dpy); FreeDisplayLock(dpy);
...@@ -961,14 +947,13 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -961,14 +947,13 @@ void _XFreeDisplayStructure(Display *dpy)
while (qelt) { while (qelt) {
register _XQEvent *qnxt = qelt->next; register _XQEvent *qnxt = qelt->next;
Xfree ((char *) qelt); Xfree (qelt);
qelt = qnxt; qelt = qnxt;
} }
} }
while (dpy->im_fd_info) { while (dpy->im_fd_info) {
struct _XConnectionInfo *conni = dpy->im_fd_info; struct _XConnectionInfo *conni = dpy->im_fd_info;
dpy->im_fd_info = conni->next; dpy->im_fd_info = conni->next;
if (conni->watch_data)
Xfree (conni->watch_data); Xfree (conni->watch_data);
Xfree (conni); Xfree (conni);
} }
...@@ -977,14 +962,14 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -977,14 +962,14 @@ void _XFreeDisplayStructure(Display *dpy)
dpy->conn_watchers = watcher->next; dpy->conn_watchers = watcher->next;
Xfree (watcher); Xfree (watcher);
} }
if (dpy->filedes)
Xfree (dpy->filedes); Xfree (dpy->filedes);
#if USE_XCB #if USE_XCB
_XFreeX11XCBStructure(dpy); _XFreeX11XCBStructure(dpy);
#endif /* USE_XCB */ #endif /* USE_XCB */
Xfree ((char *)dpy); Xfree (dpy);
} }
/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL /* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
......
...@@ -38,8 +38,8 @@ XPixmapFormatValues *XListPixmapFormats ( ...@@ -38,8 +38,8 @@ XPixmapFormatValues *XListPixmapFormats (
Display *dpy, Display *dpy,
int *count) /* RETURN */ int *count) /* RETURN */
{ {
XPixmapFormatValues *formats = (XPixmapFormatValues *) XPixmapFormatValues *formats =
Xmalloc((unsigned) (dpy->nformats * sizeof (XPixmapFormatValues))); Xmalloc(dpy->nformats * sizeof (XPixmapFormatValues));
if (formats) { if (formats) {
register int i; register int i;
......
...@@ -95,8 +95,7 @@ InsertEdgeInET( ...@@ -95,8 +95,7 @@ InsertEdgeInET(
{ {
if (*iSLLBlock > SLLSPERBLOCK-1) if (*iSLLBlock > SLLSPERBLOCK-1)
{ {
tmpSLLBlock = tmpSLLBlock = Xmalloc(sizeof(ScanLineListBlock));
(ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock));
(*SLLBlock)->next = tmpSLLBlock; (*SLLBlock)->next = tmpSLLBlock;
tmpSLLBlock->next = (ScanLineListBlock *)NULL; tmpSLLBlock->next = (ScanLineListBlock *)NULL;
*SLLBlock = tmpSLLBlock; *SLLBlock = tmpSLLBlock;
...@@ -379,7 +378,7 @@ FreeStorage( ...@@ -379,7 +378,7 @@ FreeStorage(
while (pSLLBlock) while (pSLLBlock)
{ {
tmpSLLBlock = pSLLBlock->next; tmpSLLBlock = pSLLBlock->next;
Xfree((char *)pSLLBlock); Xfree(pSLLBlock);
pSLLBlock = tmpSLLBlock; pSLLBlock = tmpSLLBlock;
} }
} }
...@@ -410,8 +409,7 @@ static int PtsToRegion( ...@@ -410,8 +409,7 @@ static int PtsToRegion(
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1; numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects, if (!(reg->rects = Xrealloc(reg->rects, sizeof(BOX) * numRects))) {
(unsigned) (sizeof(BOX) * numRects)))) {
Xfree(prevRects); Xfree(prevRects);
return(0); return(0);
} }
...@@ -521,8 +519,7 @@ XPolygonRegion( ...@@ -521,8 +519,7 @@ XPolygonRegion(
if (Count < 2) return region; if (Count < 2) return region;
if (! (pETEs = (EdgeTableEntry *) if (! (pETEs = Xmalloc(sizeof(EdgeTableEntry) * Count))) {
Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) {
XDestroyRegion(region); XDestroyRegion(region);
return (Region) NULL; return (Region) NULL;
} }
...@@ -559,7 +556,7 @@ XPolygonRegion( ...@@ -559,7 +556,7 @@ XPolygonRegion(
* send out the buffer * send out the buffer
*/ */
if (iPts == NUMPTSTOBUFFER) { if (iPts == NUMPTSTOBUFFER) {
tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK)); tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
curPtBlock->next = tmpPtBlock; curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock; curPtBlock = tmpPtBlock;
pts = curPtBlock->pts; pts = curPtBlock->pts;
...@@ -605,7 +602,7 @@ XPolygonRegion( ...@@ -605,7 +602,7 @@ XPolygonRegion(
* send out the buffer * send out the buffer
*/ */
if (iPts == NUMPTSTOBUFFER) { if (iPts == NUMPTSTOBUFFER) {
tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK)); tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
curPtBlock->next = tmpPtBlock; curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock; curPtBlock = tmpPtBlock;
pts = curPtBlock->pts; pts = curPtBlock->pts;
...@@ -630,9 +627,9 @@ XPolygonRegion( ...@@ -630,9 +627,9 @@ XPolygonRegion(
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); (void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) { for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
tmpPtBlock = curPtBlock->next; tmpPtBlock = curPtBlock->next;
Xfree((char *)curPtBlock); Xfree(curPtBlock);
curPtBlock = tmpPtBlock; curPtBlock = tmpPtBlock;
} }
Xfree((char *)pETEs); Xfree(pETEs);
return(region); return(region);
} }
...@@ -203,7 +203,8 @@ XDrawText16( ...@@ -203,7 +203,8 @@ XDrawText16(
elt->len = PartialNChars; elt->len = PartialNChars;
memcpy ((char *) (elt + 1), (char *)CharacterOffset, memcpy ((char *) (elt + 1), (char *)CharacterOffset,
PartialNChars * 2); PartialNChars *
2);
} }
} }
item++; item++;
......
...@@ -66,7 +66,6 @@ XcmsPrefixOfFormat( ...@@ -66,7 +66,6 @@ XcmsPrefixOfFormat(
*/ */
{ {
XcmsColorSpace **papColorSpaces; XcmsColorSpace **papColorSpaces;
char *prefix;
/* /*
* First try Device-Independent color spaces * First try Device-Independent color spaces
...@@ -75,10 +74,7 @@ XcmsPrefixOfFormat( ...@@ -75,10 +74,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) { if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) { while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) { if ((*papColorSpaces)->id == id) {
prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + return strdup((*papColorSpaces)->prefix);
1) * sizeof(char));
strcpy(prefix, (*papColorSpaces)->prefix);
return(prefix);
} }
papColorSpaces++; papColorSpaces++;
} }
...@@ -91,10 +87,7 @@ XcmsPrefixOfFormat( ...@@ -91,10 +87,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) { if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) { while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) { if ((*papColorSpaces)->id == id) {
prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + return strdup((*papColorSpaces)->prefix);
1) * sizeof(char));
strcpy(prefix, (*papColorSpaces)->prefix);
return(prefix);
} }
papColorSpaces++; papColorSpaces++;
} }
......
...@@ -39,37 +39,31 @@ in this Software without prior written authorization from The Open Group. ...@@ -39,37 +39,31 @@ in this Software without prior written authorization from The Open Group.
XSizeHints *XAllocSizeHints (void) XSizeHints *XAllocSizeHints (void)
{ {
return ((XSizeHints *) Xcalloc (1, (unsigned) sizeof (XSizeHints))); return Xcalloc (1, sizeof (XSizeHints));
} }
XStandardColormap *XAllocStandardColormap (void) XStandardColormap *XAllocStandardColormap (void)
{ {
return ((XStandardColormap *) return Xcalloc (1, sizeof (XStandardColormap));
Xcalloc (1, (unsigned) sizeof (XStandardColormap)));
} }
XWMHints *XAllocWMHints (void) XWMHints *XAllocWMHints (void)
{ {
return ((XWMHints *) Xcalloc (1, (unsigned) sizeof (XWMHints))); return Xcalloc (1, sizeof (XWMHints));
} }
XClassHint *XAllocClassHint (void) XClassHint *XAllocClassHint (void)
{ {
register XClassHint *h; return Xcalloc (1, sizeof (XClassHint));
if ((h = (XClassHint *) Xcalloc (1, (unsigned) sizeof (XClassHint))))
h->res_name = h->res_class = NULL;
return h;
} }
XIconSize *XAllocIconSize (void) XIconSize *XAllocIconSize (void)
{ {
return ((XIconSize *) Xcalloc (1, (unsigned) sizeof (XIconSize))); return Xcalloc (1, sizeof (XIconSize));
} }
...@@ -41,7 +41,7 @@ _XPutBackEvent ( ...@@ -41,7 +41,7 @@ _XPutBackEvent (
XEvent store = *event; XEvent store = *event;
if (!dpy->qfree) { if (!dpy->qfree) {
if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) { if ((dpy->qfree = Xmalloc (sizeof (_XQEvent))) == NULL) {
return 0; return 0;
} }
dpy->qfree->next = NULL; dpy->qfree->next = NULL;
......
...@@ -600,15 +600,9 @@ static int const HalfOrderWord[12] = { ...@@ -600,15 +600,9 @@ static int const HalfOrderWord[12] = {
/* Cancel a GetReq operation, before doing _XSend or Data */ /* Cancel a GetReq operation, before doing _XSend or Data */
#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
#define UnGetReq(name)\ #define UnGetReq(name)\
dpy->bufptr -= SIZEOF(x##name##Req);\ dpy->bufptr -= SIZEOF(x##name##Req);\
dpy->request-- dpy->request--
#else
#define UnGetReq(name)\
dpy->bufptr -= SIZEOF(x/**/name/**/Req);\
dpy->request--
#endif
static void static void
SendXYImage( SendXYImage(
...@@ -680,7 +674,7 @@ SendXYImage( ...@@ -680,7 +674,7 @@ SendXYImage(
length = ROUNDUP(length, 4); length = ROUNDUP(length, 4);
if ((dpy->bufptr + length) > dpy->bufmax) { if ((dpy->bufptr + length) > dpy->bufmax) {
if ((buf = _XAllocScratch(dpy, (unsigned long) (length))) == NULL) { if ((buf = _XAllocScratch(dpy, length)) == NULL) {
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
...@@ -703,13 +697,13 @@ SendXYImage( ...@@ -703,13 +697,13 @@ SendXYImage(
bytes_per_temp_plane = bytes_per_line * req->height; bytes_per_temp_plane = bytes_per_line * req->height;
temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4); temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4);
if (buf == dpy->bufptr) { if (buf == dpy->bufptr) {
if (! (temp = _XAllocScratch(dpy, (unsigned long) temp_length))) { if (! (temp = _XAllocScratch(dpy, temp_length))) {
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
} }
else else
if ((extra = temp = Xmalloc((unsigned) temp_length)) == NULL) { if ((extra = temp = Xmalloc(temp_length)) == NULL) {
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
...@@ -746,7 +740,6 @@ SendXYImage( ...@@ -746,7 +740,6 @@ SendXYImage(
bytes_per_src, bytes_per_line, bytes_per_src, bytes_per_line,
bytes_per_dest, req->height, half_order); bytes_per_dest, req->height, half_order);
if (extra)
Xfree(extra); Xfree(extra);
if (buf == dpy->bufptr) if (buf == dpy->bufptr)
...@@ -778,8 +771,7 @@ SendZImage( ...@@ -778,8 +771,7 @@ SendZImage(
(req_yoffset * image->bytes_per_line) + (req_yoffset * image->bytes_per_line) +
((req_xoffset * image->bits_per_pixel) >> 3); ((req_xoffset * image->bits_per_pixel) >> 3);
if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) { if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) {
if (! (shifted_src = (unsigned char *) if (! (shifted_src = Xmalloc(req->height * image->bytes_per_line))) {
Xmalloc((unsigned) (req->height * image->bytes_per_line)))) {
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
...@@ -800,8 +792,7 @@ SendZImage( ...@@ -800,8 +792,7 @@ SendZImage(
((req_xoffset == 0) || ((req_xoffset == 0) ||
((req_yoffset + req->height) < (unsigned)image->height))) { ((req_yoffset + req->height) < (unsigned)image->height))) {
Data(dpy, (char *)src, length); Data(dpy, (char *)src, length);
if (shifted_src) Xfree(shifted_src);
Xfree((char *)shifted_src);
return; return;
} }
...@@ -810,8 +801,8 @@ SendZImage( ...@@ -810,8 +801,8 @@ SendZImage(
dest = (unsigned char *)dpy->bufptr; dest = (unsigned char *)dpy->bufptr;
else else
if ((dest = (unsigned char *) if ((dest = (unsigned char *)
_XAllocScratch(dpy, (unsigned long)(length))) == NULL) { _XAllocScratch(dpy, length)) == NULL) {
if (shifted_src) Xfree((char *) shifted_src); Xfree(shifted_src);
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
...@@ -838,8 +829,7 @@ SendZImage( ...@@ -838,8 +829,7 @@ SendZImage(
else else
_XSend(dpy, (char *)dest, length); _XSend(dpy, (char *)dest, length);
if (shifted_src) Xfree(shifted_src);
Xfree((char *)shifted_src);
} }
static void static void
...@@ -1001,7 +991,7 @@ XPutImage ( ...@@ -1001,7 +991,7 @@ XPutImage (
img.bits_per_pixel = dest_bits_per_pixel; img.bits_per_pixel = dest_bits_per_pixel;
img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width), img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width),
dest_scanline_pad) >> 3; dest_scanline_pad) >> 3;
img.data = Xmalloc((unsigned) (img.bytes_per_line * height)); img.data = Xmalloc(img.bytes_per_line * height);
if (img.data == NULL) if (img.data == NULL)
return 0; return 0;
_XInitImageFuncPtrs(&img); _XInitImageFuncPtrs(&img);
......
...@@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group. ...@@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group.
#endif #endif
#include "Xlibint.h" #include "Xlibint.h"
int static void
XQueryColors( _XQueryColors(
register Display *dpy, register Display *dpy,
Colormap cmap, Colormap cmap,
XColor *defs, /* RETURN */ XColor *defs, /* RETURN */
...@@ -40,11 +40,10 @@ XQueryColors( ...@@ -40,11 +40,10 @@ XQueryColors(
xQueryColorsReply rep; xQueryColorsReply rep;
register xQueryColorsReq *req; register xQueryColorsReq *req;
LockDisplay(dpy);
GetReq(QueryColors, req); GetReq(QueryColors, req);
req->cmap = cmap; req->cmap = cmap;
req->length += ncolors; /* each pixel is a CARD32 */ SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */
for (i = 0; i < ncolors; i++) for (i = 0; i < ncolors; i++)
Data32 (dpy, (long *)&defs[i].pixel, 4L); Data32 (dpy, (long *)&defs[i].pixel, 4L);
...@@ -65,13 +64,36 @@ XQueryColors( ...@@ -65,13 +64,36 @@ XQueryColors(
def->blue = rgb->blue; def->blue = rgb->blue;
def->flags = DoRed | DoGreen | DoBlue; def->flags = DoRed | DoGreen | DoBlue;
} }
Xfree((char *)color); Xfree(color);
} }
else else
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
} }
}
int
XQueryColors(
register Display * const dpy,
const Colormap cmap,
XColor *defs, /* RETURN */
int ncolors)
{
int n;
if (dpy->bigreq_size > 0)
n = dpy->bigreq_size - (sizeof (xQueryColorsReq) >> 2) - 1;
else
n = dpy->max_request_size - (sizeof (xQueryColorsReq) >> 2);
LockDisplay(dpy);
while (ncolors >= n) {
_XQueryColors(dpy, cmap, defs, n);
defs += n;
ncolors -= n;
}
if (ncolors > 0)
_XQueryColors(dpy, cmap, defs, ncolors);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return 1; return 1;
} }
...@@ -186,15 +186,14 @@ ExpandQuarkTable(void) ...@@ -186,15 +186,14 @@ ExpandQuarkTable(void)
newmask = (oldmask << 1) + 1; newmask = (oldmask << 1) + 1;
else { else {
if (!stringTable) { if (!stringTable) {
stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) * stringTable = Xmalloc(sizeof(XrmString *) * CHUNKPER);
CHUNKPER);
if (!stringTable) if (!stringTable)
return False; return False;
stringTable[0] = (XrmString *)NULL; stringTable[0] = (XrmString *)NULL;
} }
#ifdef PERMQ #ifdef PERMQ
if (!permTable) if (!permTable)
permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER); permTable = Xmalloc(sizeof(Bits *) * CHUNKPER);
if (!permTable) if (!permTable)
return False; return False;
#endif #endif
...@@ -206,10 +205,9 @@ ExpandQuarkTable(void) ...@@ -206,10 +205,9 @@ ExpandQuarkTable(void)
#endif #endif
newmask = 0x1ff; newmask = 0x1ff;
} }
entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1)); entries = Xcalloc(newmask + 1, sizeof(Entry));
if (!entries) if (!entries)
return False; return False;
bzero((char *)entries, sizeof(Entry) * (newmask + 1));
quarkTable = entries; quarkTable = entries;
quarkMask = newmask; quarkMask = newmask;
quarkRehash = quarkMask - 2; quarkRehash = quarkMask - 2;
...@@ -232,7 +230,7 @@ ExpandQuarkTable(void) ...@@ -232,7 +230,7 @@ ExpandQuarkTable(void)
} }
} }
if (oldmask) if (oldmask)
Xfree((char *)oldentries); Xfree(oldentries);
return True; return True;
} }
...@@ -290,13 +288,13 @@ nomatch: if (!rehash) ...@@ -290,13 +288,13 @@ nomatch: if (!rehash)
q = nextQuark; q = nextQuark;
if (!(q & QUANTUMMASK)) { if (!(q & QUANTUMMASK)) {
if (!(q & CHUNKMASK)) { if (!(q & CHUNKMASK)) {
if (!(new = Xrealloc((char *)stringTable, if (!(new = Xrealloc(stringTable,
sizeof(XrmString *) * sizeof(XrmString *) *
((q >> QUANTUMSHIFT) + CHUNKPER)))) ((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail; goto fail;
stringTable = (XrmString **)new; stringTable = (XrmString **)new;
#ifdef PERMQ #ifdef PERMQ
if (!(new = Xrealloc((char *)permTable, if (!(new = Xrealloc(permTable,
sizeof(Bits *) * sizeof(Bits *) *
((q >> QUANTUMSHIFT) + CHUNKPER)))) ((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail; goto fail;
......
...@@ -137,7 +137,7 @@ XReadBitmapFileData ( ...@@ -137,7 +137,7 @@ XReadBitmapFileData (
/* error cleanup and return macro */ /* error cleanup and return macro */
#define RETURN(code) \ #define RETURN(code) \
{ if (bits) Xfree ((char *)bits); fclose (fstream); return code; } { Xfree (bits); fclose (fstream); return code; }
while (fgets(line, MAX_SIZE, fstream)) { while (fgets(line, MAX_SIZE, fstream)) {
if (strlen(line) == MAX_SIZE-1) if (strlen(line) == MAX_SIZE-1)
...@@ -191,7 +191,7 @@ XReadBitmapFileData ( ...@@ -191,7 +191,7 @@ XReadBitmapFileData (
bytes_per_line = (ww+7)/8 + padding; bytes_per_line = (ww+7)/8 + padding;
size = bytes_per_line * hh; size = bytes_per_line * hh;
bits = (unsigned char *) Xmalloc ((unsigned int) size); bits = Xmalloc (size);
if (!bits) if (!bits)
RETURN (BitmapNoMemory); RETURN (BitmapNoMemory);
...@@ -216,6 +216,11 @@ XReadBitmapFileData ( ...@@ -216,6 +216,11 @@ XReadBitmapFileData (
*ptr=value; *ptr=value;
} }
} }
/* If we got to this point, we read a full bitmap file. Break so we don't
* start reading another one from the same file and leak the memory
* allocated for the previous one. */
break;
} /* end while */ } /* end while */
fclose(fstream); fclose(fstream);
...@@ -249,7 +254,7 @@ XReadBitmapFile ( ...@@ -249,7 +254,7 @@ XReadBitmapFile (
if (res != BitmapSuccess) if (res != BitmapSuccess)
return res; return res;
*pixmap = XCreateBitmapFromData(display, d, (char *)data, *width, *height); *pixmap = XCreateBitmapFromData(display, d, (char *)data, *width, *height);
Xfree((char *)data); Xfree(data);
if (*pixmap == None) if (*pixmap == None)
return (BitmapNoMemory); return (BitmapNoMemory);
return (BitmapSuccess); return (BitmapSuccess);
......
...@@ -41,7 +41,6 @@ Status XReconfigureWMWindow ( ...@@ -41,7 +41,6 @@ Status XReconfigureWMWindow (
unsigned int mask, unsigned int mask,
XWindowChanges *changes) XWindowChanges *changes)
{ {
XConfigureRequestEvent ev;
Window root = RootWindow (dpy, screen); Window root = RootWindow (dpy, screen);
_XAsyncHandler async; _XAsyncHandler async;
_XAsyncErrorState async_state; _XAsyncErrorState async_state;
...@@ -120,20 +119,24 @@ Status XReconfigureWMWindow ( ...@@ -120,20 +119,24 @@ Status XReconfigureWMWindow (
/* /*
* If the request succeeded, then everything is okay; otherwise, send event * If the request succeeded, then everything is okay; otherwise, send event
*/ */
if (!async_state.error_count) return True; if (!async_state.error_count)
return True;
ev.type = ConfigureRequest; else {
ev.window = w; XConfigureRequestEvent ev = {
ev.parent = root; .type = ConfigureRequest,
ev.value_mask = (mask & AllMaskBits); .window = w,
ev.x = changes->x; .parent = root,
ev.y = changes->y; .value_mask = (mask & AllMaskBits),
ev.width = changes->width; .x = changes->x,
ev.height = changes->height; .y = changes->y,
ev.border_width = changes->border_width; .width = changes->width,
ev.above = changes->sibling; .height = changes->height,
ev.detail = changes->stack_mode; .border_width = changes->border_width,
.above = changes->sibling,
.detail = changes->stack_mode,
};
return (XSendEvent (dpy, root, False, return (XSendEvent (dpy, root, False,
SubstructureRedirectMask|SubstructureNotifyMask, SubstructureRedirectMask|SubstructureNotifyMask,
(XEvent *)&ev)); (XEvent *)&ev));
}
} }
...@@ -139,10 +139,10 @@ XCreateRegion(void) ...@@ -139,10 +139,10 @@ XCreateRegion(void)
{ {
Region temp; Region temp;
if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION )))) if (! (temp = Xmalloc(sizeof( REGION ))))
return (Region) NULL; return (Region) NULL;
if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) { if (! (temp->rects = Xmalloc(sizeof( BOX )))) {
Xfree((char *) temp); Xfree(temp);
return (Region) NULL; return (Region) NULL;
} }
temp->numRects = 0; temp->numRects = 0;
...@@ -384,7 +384,12 @@ XShrinkRegion( ...@@ -384,7 +384,12 @@ XShrinkRegion(
int grow; int grow;
if (!dx && !dy) return 0; if (!dx && !dy) return 0;
if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0; if (! (s = XCreateRegion()) )
return 0;
if (! (t = XCreateRegion()) ) {
XDestroyRegion(s);
return 0;
}
if ((grow = (dx < 0))) dx = -dx; if ((grow = (dx < 0))) dx = -dx;
if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow); if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow);
if ((grow = (dy < 0))) dy = -dy; if ((grow = (dy < 0))) dy = -dy;
...@@ -502,7 +507,7 @@ XIntersectRegion( ...@@ -502,7 +507,7 @@ XIntersectRegion(
return 1; return 1;
} }
static void static int
miRegionCopy( miRegionCopy(
register Region dstrgn, register Region dstrgn,
register Region rgn) register Region rgn)
...@@ -516,11 +521,12 @@ miRegionCopy( ...@@ -516,11 +521,12 @@ miRegionCopy(
{ {
BOX *prevRects = dstrgn->rects; BOX *prevRects = dstrgn->rects;
if (! (dstrgn->rects = (BOX *) dstrgn->rects = Xrealloc(dstrgn->rects,
Xrealloc((char *) dstrgn->rects, rgn->numRects * (sizeof(BOX)));
(unsigned) rgn->numRects * (sizeof(BOX))))) { if (! dstrgn->rects) {
Xfree(prevRects); Xfree(prevRects);
return; dstrgn->size = 0;
return 0;
} }
} }
dstrgn->size = rgn->numRects; dstrgn->size = rgn->numRects;
...@@ -534,6 +540,7 @@ miRegionCopy( ...@@ -534,6 +540,7 @@ miRegionCopy(
memcpy((char *) dstrgn->rects, (char *) rgn->rects, memcpy((char *) dstrgn->rects, (char *) rgn->rects,
(int) (rgn->numRects * sizeof(BOX))); (int) (rgn->numRects * sizeof(BOX)));
} }
return 1;
} }
/*====================================================================== /*======================================================================
...@@ -783,8 +790,7 @@ miRegionOp( ...@@ -783,8 +790,7 @@ miRegionOp(
*/ */
newReg->size = max(reg1->numRects,reg2->numRects) * 2; newReg->size = max(reg1->numRects,reg2->numRects) * 2;
if (! (newReg->rects = (BoxPtr) if (! (newReg->rects = Xmalloc (sizeof(BoxRec) * newReg->size))) {
Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) {
newReg->size = 0; newReg->size = 0;
return; return;
} }
...@@ -974,11 +980,12 @@ miRegionOp( ...@@ -974,11 +980,12 @@ miRegionOp(
if (REGION_NOT_EMPTY(newReg)) if (REGION_NOT_EMPTY(newReg))
{ {
BoxPtr prev_rects = newReg->rects; BoxPtr prev_rects = newReg->rects;
newReg->size = newReg->numRects; newReg->rects = Xrealloc (newReg->rects,
newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects, sizeof(BoxRec) * newReg->numRects);
(unsigned) (sizeof(BoxRec) * newReg->size));
if (! newReg->rects) if (! newReg->rects)
newReg->rects = prev_rects; newReg->rects = prev_rects;
else
newReg->size = newReg->numRects;
} }
else else
{ {
...@@ -987,11 +994,11 @@ miRegionOp( ...@@ -987,11 +994,11 @@ miRegionOp(
* the region is empty * the region is empty
*/ */
newReg->size = 1; newReg->size = 1;
Xfree((char *) newReg->rects); Xfree(newReg->rects);
newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec)); newReg->rects = Xmalloc(sizeof(BoxRec));
} }
} }
Xfree ((char *) oldRects); Xfree (oldRects);
return; return;
} }
...@@ -1146,7 +1153,7 @@ XUnionRegion( ...@@ -1146,7 +1153,7 @@ XUnionRegion(
if ( (reg1 == reg2) || (!(reg1->numRects)) ) if ( (reg1 == reg2) || (!(reg1->numRects)) )
{ {
if (newReg != reg2) if (newReg != reg2)
miRegionCopy(newReg, reg2); return miRegionCopy(newReg, reg2);
return 1; return 1;
} }
...@@ -1156,7 +1163,7 @@ XUnionRegion( ...@@ -1156,7 +1163,7 @@ XUnionRegion(
if (!(reg2->numRects)) if (!(reg2->numRects))
{ {
if (newReg != reg1) if (newReg != reg1)
miRegionCopy(newReg, reg1); return miRegionCopy(newReg, reg1);
return 1; return 1;
} }
...@@ -1170,7 +1177,7 @@ XUnionRegion( ...@@ -1170,7 +1177,7 @@ XUnionRegion(
(reg1->extents.y2 >= reg2->extents.y2)) (reg1->extents.y2 >= reg2->extents.y2))
{ {
if (newReg != reg1) if (newReg != reg1)
miRegionCopy(newReg, reg1); return miRegionCopy(newReg, reg1);
return 1; return 1;
} }
...@@ -1184,7 +1191,7 @@ XUnionRegion( ...@@ -1184,7 +1191,7 @@ XUnionRegion(
(reg2->extents.y2 >= reg1->extents.y2)) (reg2->extents.y2 >= reg1->extents.y2))
{ {
if (newReg != reg2) if (newReg != reg2)
miRegionCopy(newReg, reg2); return miRegionCopy(newReg, reg2);
return 1; return 1;
} }
...@@ -1425,8 +1432,7 @@ XSubtractRegion( ...@@ -1425,8 +1432,7 @@ XSubtractRegion(
if ( (!(regM->numRects)) || (!(regS->numRects)) || if ( (!(regM->numRects)) || (!(regS->numRects)) ||
(!EXTENTCHECK(&regM->extents, &regS->extents)) ) (!EXTENTCHECK(&regM->extents, &regS->extents)) )
{ {
miRegionCopy(regD, regM); return miRegionCopy(regD, regM);
return 1;
} }
miRegionOp (regD, regM, regS, miSubtractO, miRegionOp (regD, regM, regS, miSubtractO,
...@@ -1448,8 +1454,12 @@ XXorRegion(Region sra, Region srb, Region dr) ...@@ -1448,8 +1454,12 @@ XXorRegion(Region sra, Region srb, Region dr)
{ {
Region tra, trb; Region tra, trb;
if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion()))) if (! (tra = XCreateRegion()) )
return 0;
if (! (trb = XCreateRegion()) ) {
XDestroyRegion(tra);
return 0; return 0;
}
(void) XSubtractRegion(sra,srb,tra); (void) XSubtractRegion(sra,srb,tra);
(void) XSubtractRegion(srb,sra,trb); (void) XSubtractRegion(srb,sra,trb);
(void) XUnionRegion(tra,trb,dr); (void) XUnionRegion(tra,trb,dr);
......
...@@ -66,7 +66,7 @@ _XFreeIMFilters( ...@@ -66,7 +66,7 @@ _XFreeIMFilters(
while ((fl = display->im_filters)) { while ((fl = display->im_filters)) {
display->im_filters = fl->next; display->im_filters = fl->next;
Xfree((char *)fl); Xfree(fl);
} }
} }
...@@ -85,7 +85,7 @@ _XRegisterFilterByMask( ...@@ -85,7 +85,7 @@ _XRegisterFilterByMask(
{ {
XFilterEventRec *rec; XFilterEventRec *rec;
rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec)); rec = Xmalloc(sizeof(XFilterEventRec));
if (!rec) if (!rec)
return; return;
rec->window = window; rec->window = window;
...@@ -117,7 +117,7 @@ _XRegisterFilterByType( ...@@ -117,7 +117,7 @@ _XRegisterFilterByType(
{ {
XFilterEventRec *rec; XFilterEventRec *rec;
rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec)); rec = Xmalloc(sizeof(XFilterEventRec));
if (!rec) if (!rec)
return; return;
rec->window = window; rec->window = window;
...@@ -148,7 +148,7 @@ _XUnregisterFilter( ...@@ -148,7 +148,7 @@ _XUnregisterFilter(
if (fl->window == window && if (fl->window == window &&
fl->filter == filter && fl->client_data == client_data) { fl->filter == filter && fl->client_data == client_data) {
*prev = fl->next; *prev = fl->next;
Xfree((char *)fl); Xfree(fl);
} else } else
prev = &fl->next; prev = &fl->next;
} }
......
...@@ -57,3 +57,5 @@ XRestackWindows ( ...@@ -57,3 +57,5 @@ XRestackWindows (
} }
...@@ -48,7 +48,6 @@ char *XScreenResourceString(Screen *screen) ...@@ -48,7 +48,6 @@ char *XScreenResourceString(Screen *screen)
(unsigned char **) &val) == Success) { (unsigned char **) &val) == Success) {
if ((actual_type == XA_STRING) && (actual_format == 8)) if ((actual_type == XA_STRING) && (actual_format == 8))
return val; return val;
if (val)
Xfree(val); Xfree(val);
} }
return (char *)NULL; return (char *)NULL;
......
...@@ -78,3 +78,4 @@ XSetClipRectangles ( ...@@ -78,3 +78,4 @@ XSetClipRectangles (
SyncHandle(); SyncHandle();
return 1; return 1;
} }
...@@ -52,7 +52,7 @@ XSetFontPath ( ...@@ -52,7 +52,7 @@ XSetFontPath (
} }
nbytes = (n + 3) & ~3; nbytes = (n + 3) & ~3;
req->length += nbytes >> 2; req->length += nbytes >> 2;
if ((p = (char *) Xmalloc ((unsigned) nbytes))) { if ((p = Xmalloc (nbytes))) {
/* /*
* pack into counted strings. * pack into counted strings.
*/ */
...@@ -65,7 +65,7 @@ XSetFontPath ( ...@@ -65,7 +65,7 @@ XSetFontPath (
p += length + 1; p += length + 1;
} }
Data (dpy, tmp, nbytes); Data (dpy, tmp, nbytes);
Xfree ((char *) tmp); Xfree (tmp);
retCode = 1; retCode = 1;
} }
else else
......
...@@ -237,7 +237,7 @@ _XcmsSetGetColors( ...@@ -237,7 +237,7 @@ _XcmsSetGetColors(
/* /*
* Allocate space for XColors * Allocate space for XColors
*/ */
if ((pXColors_in_out = (XColor *)Xcalloc(nColors, sizeof(XColor))) == if ((pXColors_in_out = Xcalloc(nColors, sizeof(XColor))) ==
NULL) { NULL) {
return(XcmsFailure); return(XcmsFailure);
} }
...@@ -251,7 +251,7 @@ _XcmsSetGetColors( ...@@ -251,7 +251,7 @@ _XcmsSetGetColors(
*/ */
if ((retval = XcmsConvertColors(ccc, pColors_in_out, nColors, XcmsRGBFormat, if ((retval = XcmsConvertColors(ccc, pColors_in_out, nColors, XcmsRGBFormat,
pCompressed)) == XcmsFailure) { pCompressed)) == XcmsFailure) {
Xfree((char *)pXColors_in_out); Xfree(pXColors_in_out);
return(XcmsFailure); return(XcmsFailure);
} }
...@@ -268,12 +268,12 @@ Query: ...@@ -268,12 +268,12 @@ Query:
/* Note: XQueryColors and XStoreColors do not return any Status */ /* Note: XQueryColors and XStoreColors do not return any Status */
(*xColorProc)(ccc->dpy, cmap, pXColors_in_out, nColors); (*xColorProc)(ccc->dpy, cmap, pXColors_in_out, nColors);
} else { } else {
Xfree((char *)pXColors_in_out); Xfree(pXColors_in_out);
return(XcmsFailure); return(XcmsFailure);
} }
if (*xColorProc == XStoreColors) { if (*xColorProc == XStoreColors) {
Xfree((char *)pXColors_in_out); Xfree(pXColors_in_out);
return(retval); return(retval);
} }
...@@ -281,7 +281,7 @@ Query: ...@@ -281,7 +281,7 @@ Query:
* Now, convert the returned XColor (i.e., rgb) to XcmsColor structures * Now, convert the returned XColor (i.e., rgb) to XcmsColor structures
*/ */
_XColor_to_XcmsRGB(ccc, pXColors_in_out, pColors_in_out, nColors); _XColor_to_XcmsRGB(ccc, pXColors_in_out, pColors_in_out, nColors);
Xfree((char *)pXColors_in_out); Xfree(pXColors_in_out);
/* /*
* Then, convert XcmsColor structures to the original specification * Then, convert XcmsColor structures to the original specification
......
...@@ -184,7 +184,7 @@ XSetIconSizes ( ...@@ -184,7 +184,7 @@ XSetIconSizes (
#define size_of_the_real_thing sizeof /* avoid grepping screwups */ #define size_of_the_real_thing sizeof /* avoid grepping screwups */
unsigned nbytes = count * size_of_the_real_thing(xPropIconSize); unsigned nbytes = count * size_of_the_real_thing(xPropIconSize);
#undef size_of_the_real_thing #undef size_of_the_real_thing
if ((prop = pp = (xPropIconSize *) Xmalloc (nbytes))) { if ((prop = pp = Xmalloc (nbytes))) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
pp->minWidth = list->min_width; pp->minWidth = list->min_width;
pp->minHeight = list->min_height; pp->minHeight = list->min_height;
...@@ -198,7 +198,7 @@ XSetIconSizes ( ...@@ -198,7 +198,7 @@ XSetIconSizes (
XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32, XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32,
PropModeReplace, (unsigned char *) prop, PropModeReplace, (unsigned char *) prop,
count * NumPropIconSizeElements); count * NumPropIconSizeElements);
Xfree ((char *)prop); Xfree (prop);
} }
return 1; return 1;
} }
...@@ -216,7 +216,7 @@ XSetCommand ( ...@@ -216,7 +216,7 @@ XSetCommand (
for (i = 0, nbytes = 0; i < argc; i++) { for (i = 0, nbytes = 0; i < argc; i++) {
nbytes += safestrlen(argv[i]) + 1; nbytes += safestrlen(argv[i]) + 1;
} }
if ((bp = buf = Xmalloc((unsigned) nbytes))) { if ((bp = buf = Xmalloc(nbytes))) {
/* copy arguments into single buffer */ /* copy arguments into single buffer */
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (argv[i]) { if (argv[i]) {
...@@ -259,7 +259,9 @@ XSetStandardProperties ( ...@@ -259,7 +259,9 @@ XSetStandardProperties (
if (icon_string != NULL) { if (icon_string != NULL) {
XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8, XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string)); PropModeReplace,
(_Xconst unsigned char *)icon_string,
safestrlen(icon_string));
} }
if (icon_pixmap != None) { if (icon_pixmap != None) {
...@@ -297,7 +299,7 @@ XSetClassHint( ...@@ -297,7 +299,7 @@ XSetClassHint(
len_nm = safestrlen(classhint->res_name); len_nm = safestrlen(classhint->res_name);
len_cl = safestrlen(classhint->res_class); len_cl = safestrlen(classhint->res_class);
if ((class_string = s = Xmalloc((unsigned) (len_nm + len_cl + 2)))) { if ((class_string = s = Xmalloc(len_nm + len_cl + 2))) {
if (len_nm) { if (len_nm) {
strcpy(s, classhint->res_name); strcpy(s, classhint->res_name);
s += len_nm + 1; s += len_nm + 1;
......
...@@ -66,57 +66,6 @@ from The Open Group. ...@@ -66,57 +66,6 @@ from The Open Group.
#define MAXLOCALE 64 /* buffer size of locale name */ #define MAXLOCALE 64 /* buffer size of locale name */
#ifdef X_LOCALE
/* alternative setlocale() for when the OS does not provide one */
char *
_Xsetlocale(
int category,
_Xconst char *name
)
{
static char *xsl_name;
char *old_name;
XrmMethods methods;
XPointer state;
if (category != LC_CTYPE && category != LC_ALL)
return NULL;
if (!name) {
if (xsl_name)
return xsl_name;
return "C";
}
if (!*name)
name = getenv("LC_CTYPE");
if (!name || !*name)
name = getenv("LANG");
if (name && strlen(name) >= MAXLOCALE)
name = NULL;
if (!name || !*name || !_XOpenLC((char *) name))
name = "C";
old_name = xsl_name;
xsl_name = (char *)name;
methods = _XrmInitParseInfo(&state);
xsl_name = old_name;
if (!methods)
return NULL;
name = (*methods->lcname)(state);
xsl_name = Xmalloc(strlen(name) + 1);
if (!xsl_name) {
xsl_name = old_name;
(*methods->destroy)(state);
return NULL;
}
strcpy(xsl_name, name);
if (old_name)
Xfree(old_name);
(*methods->destroy)(state);
return xsl_name;
}
#else /* X_LOCALE */
#if defined(__DARWIN__) || defined(__APPLE__) || defined(__CYGWIN__) #if defined(__DARWIN__) || defined(__APPLE__) || defined(__CYGWIN__)
char * char *
...@@ -251,4 +200,3 @@ _XlcMapOSLocaleName( ...@@ -251,4 +200,3 @@ _XlcMapOSLocaleName(
return osname; return osname;
} }
#endif /* X_LOCALE */
...@@ -43,7 +43,7 @@ XSetPointerMapping ( ...@@ -43,7 +43,7 @@ XSetPointerMapping (
GetReq (SetPointerMapping, req); GetReq (SetPointerMapping, req);
req->nElts = nmaps; req->nElts = nmaps;
req->length += (nmaps + 3)>>2; req->length += (nmaps + 3)>>2;
Data (dpy, (char *)map, (long) nmaps); Data (dpy, (_Xconst char *)map, (long) nmaps);
if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0) if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
rep.success = MappingSuccess; rep.success = MappingSuccess;
UnlockDisplay(dpy); UnlockDisplay(dpy);
...@@ -74,3 +74,4 @@ XChangeKeyboardMapping ( ...@@ -74,3 +74,4 @@ XChangeKeyboardMapping (
SyncHandle(); SyncHandle();
return 0; return 0;
} }
...@@ -95,6 +95,6 @@ void XSetRGBColormaps ( ...@@ -95,6 +95,6 @@ void XSetRGBColormaps (
XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32, XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32,
PropModeReplace, (unsigned char *) data, PropModeReplace, (unsigned char *) data,
(int) (count * NumPropStandardColormapElements)); (int) (count * NumPropStandardColormapElements));
Xfree ((char *) data); Xfree (data);
} }
} }
...@@ -74,7 +74,7 @@ char *XFetchBuffer ( ...@@ -74,7 +74,7 @@ char *XFetchBuffer (
*nbytes = nitems; *nbytes = nitems;
return((char *)data); return((char *)data);
} }
if ((char *) data != NULL) Xfree ((char *)data); Xfree (data);
return(NULL); return(NULL);
} }
...@@ -94,7 +94,7 @@ XStoreBuffer ( ...@@ -94,7 +94,7 @@ XStoreBuffer (
{ {
if ((buffer < 0) || (buffer > 7)) return 0; if ((buffer < 0) || (buffer > 7)) return 0;
return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer], return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes); XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *) bytes, nbytes);
} }
int int
......
...@@ -51,6 +51,7 @@ XStoreColor( ...@@ -51,6 +51,7 @@ XStoreColor(
citem->blue = def->blue; citem->blue = def->blue;
citem->flags = def->flags; /* do_red, do_green, do_blue */ citem->flags = def->flags; /* do_red, do_green, do_blue */
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return 1; return 1;
......
...@@ -85,7 +85,7 @@ XcmsStoreColors( ...@@ -85,7 +85,7 @@ XcmsStoreColors(
* overwrite the contents. * overwrite the contents.
*/ */
if (nColors > 1) { if (nColors > 1) {
pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor)); pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
} else { } else {
pColors_tmp = &Color1; pColors_tmp = &Color1;
} }
...@@ -102,7 +102,7 @@ XcmsStoreColors( ...@@ -102,7 +102,7 @@ XcmsStoreColors(
* Free copies as needed. * Free copies as needed.
*/ */
if (nColors > 1) { if (nColors > 1) {
Xfree((char *)pColors_tmp); Xfree(pColors_tmp);
} }
/* /*
......
...@@ -37,7 +37,7 @@ XStoreName ( ...@@ -37,7 +37,7 @@ XStoreName (
_Xconst char *name) _Xconst char *name)
{ {
return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING, return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
8, PropModeReplace, (unsigned char *)name, 8, PropModeReplace, (_Xconst unsigned char *)name,
name ? strlen(name) : 0); name ? strlen(name) : 0);
} }
...@@ -47,7 +47,7 @@ XSetIconName ( ...@@ -47,7 +47,7 @@ XSetIconName (
Window w, Window w,
_Xconst char *icon_name) _Xconst char *icon_name)
{ {
return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
8, PropModeReplace, (unsigned char *)icon_name, PropModeReplace, (_Xconst unsigned char *)icon_name,
icon_name ? strlen(icon_name) : 0); icon_name ? strlen(icon_name) : 0);
} }
...@@ -27,6 +27,7 @@ in this Software without prior written authorization from The Open Group. ...@@ -27,6 +27,7 @@ in this Software without prior written authorization from The Open Group.
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <limits.h>
#include "Xlibint.h" #include "Xlibint.h"
#include <nx-X11/Xresource.h> #include <nx-X11/Xresource.h>
#include <nx-X11/keysymdef.h> #include <nx-X11/keysymdef.h>
...@@ -93,7 +94,7 @@ XStringToKeysym(_Xconst char *s) ...@@ -93,7 +94,7 @@ XStringToKeysym(_Xconst char *s)
{ {
entry = &_XkeyTable[idx]; entry = &_XkeyTable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) && if ((entry[0] == sig1) && (entry[1] == sig2) &&
!strcmp(s, (char *)entry + 6)) !strcmp(s, (const char *)entry + 6))
{ {
val = (entry[2] << 24) | (entry[3] << 16) | val = (entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | entry[5]; (entry[4] << 8) | entry[5];
...@@ -152,5 +153,29 @@ XStringToKeysym(_Xconst char *s) ...@@ -152,5 +153,29 @@ XStringToKeysym(_Xconst char *s)
return val; return val;
return val | 0x01000000; return val | 0x01000000;
} }
if (strlen(s) > 2 && s[0] == '0' && s[1] == 'x') {
char *tmp = NULL;
val = strtoul(s, &tmp, 16);
if (val == ULONG_MAX || (tmp && *tmp != '\0'))
return NoSymbol;
else
return val;
}
/* Stupid inconsistency between the headers and XKeysymDB: the former has
* no separating underscore, while some XF86* syms in the latter did.
* As a last ditch effort, try without. */
if (strncmp(s, "XF86_", 5) == 0) {
KeySym ret;
char *tmp = strdup(s);
if (!tmp)
return NoSymbol;
memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
ret = XStringToKeysym(tmp);
free(tmp);
return ret;
}
return NoSymbol; return NoSymbol;
} }
...@@ -78,7 +78,7 @@ Status XStringListToTextProperty ( ...@@ -78,7 +78,7 @@ Status XStringListToTextProperty (
} }
} }
} else { } else {
proto.value = (unsigned char *) Xmalloc (1); /* easier for client */ proto.value = Xmalloc (1); /* easier for client */
if (!proto.value) return False; if (!proto.value) return False;
proto.value[0] = '\0'; proto.value[0] = '\0';
......
...@@ -72,12 +72,12 @@ Status XTextPropertyToStringList ( ...@@ -72,12 +72,12 @@ Status XTextPropertyToStringList (
/* /*
* allocate list and duplicate * allocate list and duplicate
*/ */
list = (char **) Xmalloc (nelements * sizeof (char *)); list = Xmalloc (nelements * sizeof (char *));
if (!list) return False; if (!list) return False;
start = (char *) Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */ start = Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */
if (!start) { if (!start) {
Xfree ((char *) list); Xfree (list);
return False; return False;
} }
...@@ -111,7 +111,7 @@ void XFreeStringList (char **list) ...@@ -111,7 +111,7 @@ void XFreeStringList (char **list)
{ {
if (list) { if (list) {
if (list[0]) Xfree (list[0]); if (list[0]) Xfree (list[0]);
Xfree ((char *) list); Xfree (list);
list = NULL; list = NULL;
} }
} }
......
...@@ -81,9 +81,7 @@ typedef thread_t xthread_t; ...@@ -81,9 +81,7 @@ typedef thread_t xthread_t;
#pragma weak cond_broadcast = _Xthr_zero_stub_ #pragma weak cond_broadcast = _Xthr_zero_stub_
#else /* !SVR4 */ #else /* !SVR4 */
#ifdef WIN32 #ifdef WIN32
/* #include <nx-X11/Xthreads.h>
* Don't know what to do here. Is there something do be done at all?
*/
#else /* !WIN32 */ #else /* !WIN32 */
#ifdef USE_TIS_SUPPORT #ifdef USE_TIS_SUPPORT
#include <tis.h> #include <tis.h>
......
...@@ -75,8 +75,7 @@ XVisualInfo *XGetVisualInfo( ...@@ -75,8 +75,7 @@ XVisualInfo *XGetVisualInfo(
count = 0; count = 0;
total = 10; total = 10;
if (! (vip_base = vip = (XVisualInfo *) if (! (vip_base = vip = Xmalloc(sizeof(XVisualInfo) * total))) {
Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XVisualInfo *) NULL; return (XVisualInfo *) NULL;
} }
...@@ -132,10 +131,9 @@ XVisualInfo *XGetVisualInfo( ...@@ -132,10 +131,9 @@ XVisualInfo *XGetVisualInfo(
{ {
XVisualInfo *old_vip_base = vip_base; XVisualInfo *old_vip_base = vip_base;
total += 10; total += 10;
if (! (vip_base = (XVisualInfo *) if (! (vip_base = Xrealloc(vip_base,
Xrealloc((char *) vip_base, sizeof(XVisualInfo) * total))) {
(unsigned) (sizeof(XVisualInfo) * total)))) { Xfree(old_vip_base);
Xfree((char *) old_vip_base);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XVisualInfo *) NULL; return (XVisualInfo *) NULL;
} }
...@@ -172,7 +170,7 @@ XVisualInfo *XGetVisualInfo( ...@@ -172,7 +170,7 @@ XVisualInfo *XGetVisualInfo(
return vip_base; return vip_base;
} }
Xfree((char *) vip_base); Xfree(vip_base);
*nitems = 0; *nitems = 0;
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment