summaryrefslogtreecommitdiff
path: root/mi/mieq.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-15 03:18:13 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-15 03:20:17 -0800
commita939368ab8140d48c1da4ba0bb229d13b221189c (patch)
treec6b24da6d7632d5d4fe611ebbc30aeb1a88c847d /mi/mieq.c
parentf1c9b5ab230cbb4124d8d476ae4886d05022adcb (diff)
mi: Reuse memory in mieqProcessInputEvents rather than making excessive calls to calloc()
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com> Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'mi/mieq.c')
-rw-r--r--mi/mieq.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index a19c93979..82bbb2c94 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -312,7 +312,8 @@ mieqProcessInputEvents(void)
int x = 0, y = 0;
int type, nevents, evlen, i;
ScreenPtr screen;
- xEvent *event;
+ static xEvent *event = NULL;
+ static size_t event_size = 0;
DeviceIntPtr dev = NULL,
master = NULL;
@@ -322,7 +323,10 @@ mieqProcessInputEvents(void)
/* GenericEvents always have nevents == 1 */
nevents = e->nevents;
evlen = (nevents > 1) ? sizeof(xEvent) : e->events->evlen;
- event = xcalloc(nevents, evlen);
+ if((nevents * evlen) > event_size) {
+ event_size = nevents * evlen;
+ event = (xEvent *)xrealloc(event, event_size);
+ }
if (!event)
FatalError("[mi] No memory left for event processing.\n");
@@ -380,8 +384,6 @@ mieqProcessInputEvents(void)
master->public.processInputProc(masterEvents->event, master,
nevents);
}
-
- xfree(event);
}
/* Update the sprite now. Next event may be from different device. */