xfree86: don't call xalloc from signal handlers when posting events.
Reviewed-by: Peter Hutterer <peter@cs.unisa.edu.au>
This commit is contained in:
parent
1692dcf197
commit
c68f063be6
|
@ -133,6 +133,11 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
|
|||
|
||||
/* Backwards compatibility. */
|
||||
local->history_size = GetMotionHistorySize();
|
||||
/* Preallocate xEvent store */
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -461,6 +466,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
|
|||
* convenient functions to post events
|
||||
*/
|
||||
|
||||
#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
|
||||
|
||||
_X_EXPORT void
|
||||
xf86PostMotionEvent(DeviceIntPtr device,
|
||||
int is_absolute,
|
||||
|
@ -470,17 +477,12 @@ xf86PostMotionEvent(DeviceIntPtr device,
|
|||
{
|
||||
va_list var;
|
||||
int i = 0;
|
||||
static int *valuators = NULL;
|
||||
static int n_valuators = 0;
|
||||
static int valuators[MAX_VALUATORS];
|
||||
|
||||
if (num_valuators > n_valuators) {
|
||||
xfree (valuators);
|
||||
valuators = NULL;
|
||||
}
|
||||
|
||||
if (!valuators) {
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
n_valuators = num_valuators;
|
||||
if (num_valuators > MAX_VALUATORS) {
|
||||
xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
|
||||
" is greater than MAX_VALUATORS\n", num_valuators);
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(var, num_valuators);
|
||||
|
@ -529,9 +531,7 @@ xf86PostMotionEventP(DeviceIntPtr device,
|
|||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
FatalError("Didn't allocate event store\n");
|
||||
|
||||
nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
|
||||
flags, first_valuator, num_valuators,
|
||||
|
@ -555,9 +555,15 @@ xf86PostProximityEvent(DeviceIntPtr device,
|
|||
...)
|
||||
{
|
||||
va_list var;
|
||||
int i, nevents, *valuators = NULL;
|
||||
int i, nevents;
|
||||
int valuators[MAX_VALUATORS];
|
||||
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
|
||||
if (num_valuators > MAX_VALUATORS) {
|
||||
xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
|
||||
" is greater than MAX_VALUATORS\n", num_valuators);
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(var, num_valuators);
|
||||
for (i = 0; i < num_valuators; i++)
|
||||
|
@ -565,9 +571,7 @@ xf86PostProximityEvent(DeviceIntPtr device,
|
|||
va_end(var);
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
FatalError("Didn't allocate event store\n");
|
||||
|
||||
nevents = GetProximityEvents(xf86Events, device,
|
||||
is_in ? ProximityIn : ProximityOut,
|
||||
|
@ -575,7 +579,6 @@ xf86PostProximityEvent(DeviceIntPtr device,
|
|||
for (i = 0; i < nevents; i++)
|
||||
mieqEnqueue(device, xf86Events + i);
|
||||
|
||||
xfree(valuators);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
|
@ -588,7 +591,7 @@ xf86PostButtonEvent(DeviceIntPtr device,
|
|||
...)
|
||||
{
|
||||
va_list var;
|
||||
int *valuators = NULL;
|
||||
int valuators[MAX_VALUATORS];
|
||||
int i = 0, nevents = 0;
|
||||
int index;
|
||||
|
||||
|
@ -599,18 +602,19 @@ xf86PostButtonEvent(DeviceIntPtr device,
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
if (num_valuators > MAX_VALUATORS) {
|
||||
xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
|
||||
" is greater than MAX_VALUATORS\n", num_valuators);
|
||||
return;
|
||||
}
|
||||
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
|
||||
va_start(var, num_valuators);
|
||||
for (i = 0; i < num_valuators; i++)
|
||||
valuators[i] = va_arg(var, int);
|
||||
va_end(var);
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
FatalError("Didn't allocate event store\n");
|
||||
|
||||
nevents = GetPointerEvents(xf86Events, device,
|
||||
is_down ? ButtonPress : ButtonRelease, button,
|
||||
|
@ -620,8 +624,6 @@ xf86PostButtonEvent(DeviceIntPtr device,
|
|||
|
||||
for (i = 0; i < nevents; i++)
|
||||
mieqEnqueue(device, xf86Events + i);
|
||||
|
||||
xfree(valuators);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
|
@ -634,7 +636,8 @@ xf86PostKeyEvent(DeviceIntPtr device,
|
|||
...)
|
||||
{
|
||||
va_list var;
|
||||
int i = 0, nevents = 0, *valuators = NULL;
|
||||
int i = 0, nevents = 0;
|
||||
static int valuators[MAX_VALUATORS];
|
||||
|
||||
/* instil confidence in the user */
|
||||
DebugF("this function has never been tested properly. if things go quite "
|
||||
|
@ -642,12 +645,9 @@ xf86PostKeyEvent(DeviceIntPtr device,
|
|||
"broken.\n");
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
FatalError("Didn't allocate event store\n");
|
||||
|
||||
if (is_absolute) {
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
va_start(var, num_valuators);
|
||||
for (i = 0; i < num_valuators; i++)
|
||||
valuators[i] = va_arg(var, int);
|
||||
|
@ -657,7 +657,6 @@ xf86PostKeyEvent(DeviceIntPtr device,
|
|||
is_down ? KeyPress : KeyRelease,
|
||||
key_code, first_valuator,
|
||||
num_valuators, valuators);
|
||||
xfree(valuators);
|
||||
}
|
||||
else {
|
||||
nevents = GetKeyboardEvents(xf86Events, device,
|
||||
|
@ -686,9 +685,7 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
|
|||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
FatalError("Didn't allocate event store\n");
|
||||
|
||||
nevents = GetKeyboardEvents(xf86Events, device,
|
||||
is_down ? KeyPress : KeyRelease, key_code);
|
||||
|
|
Loading…
Reference in New Issue
Block a user