summaryrefslogtreecommitdiff
path: root/lib/libXi/src/XISelEv.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libXi/src/XISelEv.c')
-rw-r--r--lib/libXi/src/XISelEv.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/libXi/src/XISelEv.c b/lib/libXi/src/XISelEv.c
index bdc4fd1b0..f1f3fa425 100644
--- a/lib/libXi/src/XISelEv.c
+++ b/lib/libXi/src/XISelEv.c
@@ -48,11 +48,14 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks)
xXIEventMask mask;
int i;
int len = 0;
+ int r = Success;
XExtDisplayInfo *info = XInput_find_display(dpy);
LockDisplay(dpy);
- if (_XiCheckExtInit(dpy, Dont_Check, info) == -1)
- return (NoSuchExtension);
+ if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) {
+ r = NoSuchExtension;
+ goto out;
+ }
GetReq(XISelectEvents, req);
req->reqType = info->codes->major_opcode;
@@ -85,9 +88,10 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks)
free(buff);
}
+out:
UnlockDisplay(dpy);
SyncHandle();
- return Success;
+ return r;
}
@@ -100,14 +104,12 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
xXIEventMask *mask_in = NULL, *mi;
xXIGetSelectedEventsReq *req;
xXIGetSelectedEventsReply reply;
-
XExtDisplayInfo *info = XInput_find_display(dpy);
+
+ *num_masks_return = -1;
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, Dont_Check, info) == -1)
- {
- *num_masks_return = -1;
- return NULL;
- }
+ goto out;
GetReq(XIGetSelectedEvents, req);
@@ -116,17 +118,17 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
req->win = win;
if (!_XReply(dpy, (xReply *) &reply, 0, xFalse))
- goto error;
+ goto out;
if (reply.num_masks == 0)
{
*num_masks_return = 0;
- return NULL;
+ goto out;
}
mask_in = Xmalloc(reply.length * 4);
if (!mask_in)
- goto error;
+ goto out;
_XRead(dpy, (char*)mask_in, reply.length * 4);
@@ -144,7 +146,7 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
mask_out = Xmalloc(len);
if (!mask_out)
- goto error;
+ goto out;
mi = mask_in;
mask = (unsigned char*)&mask_out[reply.num_masks];
@@ -161,14 +163,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
*num_masks_return = reply.num_masks;
- return mask_out;
+out:
+ Xfree(mask_in);
-error:
- if (mask_in)
- Xfree(mask_in);
- *num_masks_return = -1;
UnlockDisplay(dpy);
SyncHandle();
- return NULL;
+ return mask_out;
}