From a548d9d0f7b889627c43b18811357fad88760b2d Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 2 May 2014 15:09:23 +0200 Subject: Fix Issue #21: automatic calculation of alignment padding after lists --- nexgb/xf86dri/xf86dri.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index d88cc5d..6a07e41 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -90,7 +90,7 @@ func (v DrmClipRect) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.X3)) b += 2 - return buf + return buf[:b] } // DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice. @@ -776,7 +776,6 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v.DevicePrivate[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -846,7 +845,8 @@ type GetDrawableInfoReply struct { BackY int16 NumBackClipRects uint32 ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) - BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) + // alignment gap to multiple of 4 + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) } // Reply blocks and returns the reply data for a GetDrawableInfo request. @@ -907,6 +907,8 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v.ClipRects = make([]DrmClipRect, v.NumClipRects) b += DrmClipRectReadList(buf[b:], v.ClipRects) + b = (b + 3) & ^3 // alignment gap + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) b += DrmClipRectReadList(buf[b:], v.BackClipRects) -- cgit v1.2.3-70-g09d2