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