aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xf86dri/xf86dri.go
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2014-05-02 15:09:23 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:22 +0200
commita548d9d0f7b889627c43b18811357fad88760b2d (patch)
tree0d4a0ad302d753638dfdb16159e03d1fb87b0872 /nexgb/xf86dri/xf86dri.go
parent1f8bd79abee5d96a41a934d1eb8c74e90ccbcc8f (diff)
downloadhaven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.gz
haven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.xz
haven-a548d9d0f7b889627c43b18811357fad88760b2d.zip
Fix Issue #21: automatic calculation of alignment padding after lists
Diffstat (limited to 'nexgb/xf86dri/xf86dri.go')
-rw-r--r--nexgb/xf86dri/xf86dri.go8
1 files changed, 5 insertions, 3 deletions
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)