diff options
author | Keith Packard <keithp@keithp.com> | 2009-09-17 18:14:31 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-20 20:45:24 +1000 |
commit | 8b5086250aa5dae8de8b763408ff480d7beac819 (patch) | |
tree | 781d7cac5662704a19c528dc590629c5382908b5 | |
parent | c7987660fd665f32406b14db7078a3f5f7b76e9c (diff) |
Eliminate bogus event resizing.
Now that all event queues hold internal events only, they never need
to be resized. Resizing them led to memory corruption as they would
get sized for an appropriate xEvent, not an internal event.
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | dix/devices.c | 13 | ||||
-rw-r--r-- | dix/getevents.c | 24 | ||||
-rw-r--r-- | include/input.h | 3 | ||||
-rw-r--r-- | mi/mi.h | 4 | ||||
-rw-r--r-- | mi/mieq.c | 21 |
5 files changed, 14 insertions, 51 deletions
diff --git a/dix/devices.c b/dix/devices.c index 62574f2cd..e86e606c0 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -281,9 +281,6 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent) DeviceIntPtr *prev; int ret; DeviceIntPtr other; - int evsize = sizeof(xEvent); - int listlen; - EventListPtr evlist; BOOL enabled; int flags[MAXDEVICES] = {0}; @@ -325,16 +322,6 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent) * list's events have enough memory for a ClassesChangedEvent from the * device */ - - evsize += SizeDeviceClasses(dev); - - listlen = GetEventList(&evlist); - OsBlockSignals(); - SetMinimumEventSize(evlist, listlen, evsize); - mieqResizeEvents(evsize); - OsReleaseSignals(); - - if ((*prev != dev) || !dev->inited || ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) { ErrorF("[dix] couldn't enable device %d\n", dev->id); diff --git a/dix/getevents.c b/dix/getevents.c index 46e508002..7ddf88bad 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -964,30 +964,6 @@ InitEventList(int num_events) } /** - * Allocs min_size memory for each event in the list. - */ -void -SetMinimumEventSize(EventListPtr list, int num_events, int min_size) -{ - if (!list) - return; - - while(num_events--) - { - if (list[num_events].evlen < min_size) - { - list[num_events].evlen = min_size; - list[num_events].event = realloc(list[num_events].event, min_size); - if (!list[num_events].event) - { - FatalError("[dix] Failed to set event list's " - "min_size to %d.\n", min_size); - } - } - } -} - -/** * Free an event list. * * @param list The list to be freed. diff --git a/include/input.h b/include/input.h index 0e5b0bf00..afcc006f8 100644 --- a/include/input.h +++ b/include/input.h @@ -409,9 +409,6 @@ extern _X_EXPORT int GetMaximumEventsNum(void); extern _X_EXPORT int GetEventList(EventListPtr* list); extern _X_EXPORT EventListPtr InitEventList(int num_events); -extern _X_EXPORT void SetMinimumEventSize(EventListPtr list, - int num_events, - int min_size); extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events); extern void CreateClassesChangedEvent(EventListPtr event, @@ -196,9 +196,7 @@ extern _X_EXPORT Bool mieqInit( void ); -extern _X_EXPORT void mieqResizeEvents( - int /* min_size */ -); +extern _X_EXPORT void mieqFini(void); extern _X_EXPORT void mieqEnqueue( DeviceIntPtr /*pDev*/, @@ -110,24 +110,29 @@ mieqInit(void) miEventQueue.handlers[i] = NULL; for (i = 0; i < QUEUE_SIZE; i++) { - EventListPtr evlist = InitEventList(1); - if (!evlist) - FatalError("Could not allocate event queue.\n"); - miEventQueue.events[i].events = evlist; + if (miEventQueue.events[i].events == NULL) { + EventListPtr evlist = InitEventList(1); + if (!evlist) + FatalError("Could not allocate event queue.\n"); + miEventQueue.events[i].events = evlist; + } } SetInputCheck(&miEventQueue.head, &miEventQueue.tail); return TRUE; } -/* Ensure all events in the EQ are at least size bytes. */ void -mieqResizeEvents(int min_size) +mieqFini(void) { int i; - for (i = 0; i < QUEUE_SIZE; i++) - SetMinimumEventSize(miEventQueue.events[i].events, 1, min_size); + { + if (miEventQueue.events[i].events != NULL) { + FreeEventList(miEventQueue.events[i].events, 1); + miEventQueue.events[i].events = NULL; + } + } } /* |