aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xselinux
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2017-01-18 10:52:16 +0100
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:27 +0200
commit3906399e7c2a40fbaf355de572cf50a314083f64 (patch)
treefcdcca7da60cc3c7c7e87faa5dcc4898d1671514 /nexgb/xselinux
parent1c01d79ba14a802c603ca2e5bbd35156e3363b85 (diff)
downloadhaven-3906399e7c2a40fbaf355de572cf50a314083f64.tar.gz
haven-3906399e7c2a40fbaf355de572cf50a314083f64.tar.xz
haven-3906399e7c2a40fbaf355de572cf50a314083f64.zip
Regenerated from xcb-proto 1.12
Diffstat (limited to 'nexgb/xselinux')
-rw-r--r--nexgb/xselinux/xselinux.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go
index 1afcc10..c237857 100644
--- a/nexgb/xselinux/xselinux.go
+++ b/nexgb/xselinux/xselinux.go
@@ -41,7 +41,9 @@ type ListItem struct {
ObjectContextLen uint32
DataContextLen uint32
ObjectContext string // size: xgb.Pad((int(ObjectContextLen) * 1))
- DataContext string // size: xgb.Pad((int(DataContextLen) * 1))
+ // alignment gap to multiple of 4
+ DataContext string // size: xgb.Pad((int(DataContextLen) * 1))
+ // alignment gap to multiple of 4
}
// ListItemRead reads a byte slice into a ListItem value.
@@ -64,6 +66,8 @@ func ListItemRead(buf []byte, v *ListItem) int {
b += int(v.ObjectContextLen)
}
+ b = (b + 3) & ^3 // alignment gap
+
{
byteString := make([]byte, v.DataContextLen)
copy(byteString[:v.DataContextLen], buf[b:])
@@ -71,6 +75,8 @@ func ListItemRead(buf []byte, v *ListItem) int {
b += int(v.DataContextLen)
}
+ b = (b + 3) & ^3 // alignment gap
+
return b
}
@@ -86,7 +92,7 @@ func ListItemReadList(buf []byte, dest []ListItem) int {
// Bytes writes a ListItem value to a byte slice.
func (v ListItem) Bytes() []byte {
- buf := make([]byte, ((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + xgb.Pad((int(v.DataContextLen) * 1))))
+ buf := make([]byte, ((((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + 4) + xgb.Pad((int(v.DataContextLen) * 1))) + 4))
b := 0
xgb.Put32(buf[b:], uint32(v.Name))
@@ -101,9 +107,13 @@ func (v ListItem) Bytes() []byte {
copy(buf[b:], v.ObjectContext[:v.ObjectContextLen])
b += int(v.ObjectContextLen)
+ b = (b + 3) & ^3 // alignment gap
+
copy(buf[b:], v.DataContext[:v.DataContextLen])
b += int(v.DataContextLen)
+ b = (b + 3) & ^3 // alignment gap
+
return buf[:b]
}
@@ -123,7 +133,7 @@ func ListItemListBytes(buf []byte, list []ListItem) int {
func ListItemListSize(list []ListItem) int {
size := 0
for _, item := range list {
- size += ((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + xgb.Pad((int(item.DataContextLen) * 1)))
+ size += ((((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + 4) + xgb.Pad((int(item.DataContextLen) * 1))) + 4)
}
return size
}