xserver: Branch 'master'

Zephaniah E. Hull warp at kemper.freedesktop.org
Mon Jun 4 03:59:38 PDT 2007


 hw/xfree86/common/xf86Xinput.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

New commits:
diff-tree fbb9b203950e9d0e82574cde5b3e006b0e6b404f (from 3f4295e643ca56c40f33af7966e8efd367ef8749)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 06:59:42 2007 -0400

    Let's not do a calloc and a free on every call to xf86PostMotionEvents.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 91e5fec..207e792 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -463,9 +463,18 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 {
     va_list var;
     int i = 0;
-    int *valuators = NULL;
-    
-    valuators = xcalloc(sizeof(int), num_valuators);
+    static int *valuators = NULL;
+    static int n_valuators = 0;
+
+    if (num_valuators > n_valuators) {
+	xfree (valuators);
+	valuators = NULL;
+    }
+
+    if (!valuators) {
+	valuators = xcalloc(sizeof(int), num_valuators);
+	n_valuators = num_valuators;
+    }
 
     va_start(var, num_valuators);
     for (i = 0; i < num_valuators; i++)
@@ -473,7 +482,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     va_end(var);
 
     xf86PostMotionEventP(device, is_absolute, first_valuator, num_valuators, valuators);
-    xfree(valuators);
 }
 
 _X_EXPORT void


More information about the xorg-commit mailing list