aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/ModMap.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11/ModMap.c')
-rw-r--r--nx-X11/lib/X11/ModMap.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/nx-X11/lib/X11/ModMap.c b/nx-X11/lib/X11/ModMap.c
index 122ca80db..49a5d08e8 100644
--- a/nx-X11/lib/X11/ModMap.c
+++ b/nx-X11/lib/X11/ModMap.c
@@ -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;
}