aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/devices.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 1bf73b992..1c2cc9807 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -1233,6 +1233,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
{
int i;
ValuatorClassPtr valc;
+ union align_u { ValuatorClassRec valc; double d; } *align;
if (!dev)
return FALSE;
@@ -1245,12 +1246,13 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
numAxes = MAX_VALUATORS;
}
- valc = (ValuatorClassPtr)calloc(1, sizeof(ValuatorClassRec) +
- numAxes * sizeof(AxisInfo) +
- numAxes * sizeof(double));
- if (!valc)
+ align = (union align_u *) calloc(1, sizeof(union align_u) +
+ numAxes * sizeof(double) +
+ numAxes * sizeof(AxisInfo));
+ if (!align)
return FALSE;
+ valc = &align->valc;
valc->sourceid = dev->id;
valc->motion = NULL;
valc->first_motion = 0;
@@ -1259,8 +1261,8 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
valc->numMotionEvents = numMotionEvents;
valc->motionHintWindow = NullWindow;
valc->numAxes = numAxes;
- valc->axes = (AxisInfoPtr)(valc + 1);
- valc->axisVal = (double *)(valc->axes + numAxes);
+ valc->axisVal = (double *)(align + 1);
+ valc->axes = (AxisInfoPtr)(valc->axisVal + numAxes);
if (mode & OutOfProximity)
InitProximityClassDeviceStruct(dev);