summaryrefslogtreecommitdiff
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-15 11:18:13 (GMT)
committer Jeremy Huddleston <jeremyhu@freedesktop.org>2008-12-15 11:20:17 (GMT)
commita939368ab8140d48c1da4ba0bb229d13b221189c (patch) (side-by-side diff)
treec6b24da6d7632d5d4fe611ebbc30aeb1a88c847d
parentf1c9b5ab230cbb4124d8d476ae4886d05022adcb (diff)
downloadxserver-a939368ab8140d48c1da4ba0bb229d13b221189c.zip
xserver-a939368ab8140d48c1da4ba0bb229d13b221189c.tar.gz
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 (more/less context) (ignore whitespace changes)
-rw-r--r--mi/mieq.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index a19c939..82bbb2c 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. */