diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-12-15 03:18:13 -0800 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-12-15 03:20:17 -0800 |
commit | a939368ab8140d48c1da4ba0bb229d13b221189c (patch) | |
tree | c6b24da6d7632d5d4fe611ebbc30aeb1a88c847d /mi/mieq.c | |
parent | f1c9b5ab230cbb4124d8d476ae4886d05022adcb (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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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. */ |