[xf86-input-synaptics v3 10/14] Add open_slots array to SynapticsPrivate

Chase Douglas chase.douglas at canonical.com
Fri Feb 10 11:56:54 PST 2012


Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 src/synaptics.c    |   35 ++++++++++++++++++++++++++---------
 src/synapticsstr.h |    1 +
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index a6b1b18..c86351d 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -814,6 +814,10 @@ static void SynapticsUnInit(InputDriverPtr drv,
     if (priv && priv->scroll_events_mask)
         valuator_mask_free(&priv->scroll_events_mask);
 #endif
+#ifdef HAVE_MULTITOUCH
+    if (priv && priv->open_slots)
+        free(priv->open_slots);
+#endif
     free(pInfo->private);
     pInfo->private = NULL;
     xf86DeleteInput(pInfo, 0);
@@ -1150,6 +1154,15 @@ DeviceInit(DeviceIntPtr dev)
     {
         priv->num_slots = priv->max_touches ? priv->max_touches : 10;
 
+        priv->open_slots = malloc(priv->num_slots * sizeof(int));
+        if (!priv->open_slots)
+        {
+            xf86IDrvMsg(pInfo, X_ERROR,
+                        "failed to allocate open touch slots array\n");
+            priv->has_touch = 0;
+            goto no_touch;
+        }
+
         /* x/y + whatever other MT axes we found */
         if (!InitTouchClassDeviceStruct(dev, priv->max_touches,
                                         XIDependentTouch, 2 + priv->num_mt_axes))
@@ -1158,6 +1171,8 @@ DeviceInit(DeviceIntPtr dev)
                         "failed to initialize touch class device\n");
             priv->has_touch = 0;
             priv->num_slots = 0;
+            free(priv->open_slots);
+            priv->open_slots = NULL;
             goto no_touch;
         }
 
@@ -1191,24 +1206,26 @@ no_touch:
 
     priv->local_hw_state = SynapticsHwStateAlloc(priv);
     if (!priv->local_hw_state)
-    {
-	free(priv->hwState);
-	return !Success;
-    }
+	goto fail;
 
     priv->comm.hwState = SynapticsHwStateAlloc(priv);
 
     if (!alloc_shm_data(pInfo))
-    {
-	free(priv->local_hw_state);
-	free(priv->hwState);
-	return !Success;
-    }
+        goto fail;
 
     InitDeviceProperties(pInfo);
     XIRegisterPropertyHandler(pInfo->dev, SetProperty, NULL, NULL);
 
     return Success;
+
+fail:
+    free_shm_data(priv);
+    free(priv->local_hw_state);
+    free(priv->hwState);
+#ifdef HAVE_MULTITOUCH
+    free(priv->open_slots);
+#endif
+    return !Success;
 }
 
 
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 1c8342c..aeaf906 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -282,6 +282,7 @@ typedef struct _SynapticsPrivateRec
     int num_mt_axes;                    /* Number of multitouch axes other than X, Y */
     SynapticsTouchAxisRec *touch_axes;  /* Touch axis information other than X, Y */
     int num_slots;                      /* Number of touch slots allocated */
+    int *open_slots;                    /* Array of currently open touch slots */
 #endif
 } SynapticsPrivate;
 
-- 
1.7.8.3



More information about the xorg-devel mailing list