Skip to content

Commit

Permalink
Fix Issue BurntSushi#21: automatic calculation of alignment padding a…
Browse files Browse the repository at this point in the history
…fter lists
  • Loading branch information
aarzilli committed May 2, 2014
1 parent efcb6d4 commit cdbc824
Show file tree
Hide file tree
Showing 30 changed files with 630 additions and 474 deletions.
7 changes: 3 additions & 4 deletions dri2/dri2.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (v AttachFormat) Bytes() []byte {
xgb.Put32(buf[b:], v.Format)
b += 4

return buf
return buf[:b]
}

// AttachFormatListBytes writes a list of AttachFormat values to a byte slice.
Expand Down Expand Up @@ -281,7 +281,7 @@ func (v DRI2Buffer) Bytes() []byte {
xgb.Put32(buf[b:], v.Flags)
b += 4

return buf
return buf[:b]
}

// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice.
Expand Down Expand Up @@ -567,7 +567,7 @@ func connectReply(buf []byte) *ConnectReply {

v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))
copy(v.AlignmentPad[:(((int(v.DriverNameLength)+3)&-4)-int(v.DriverNameLength))], buf[b:])
b += xgb.Pad(int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))))
b += int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))

{
byteString := make([]byte, v.DeviceNameLength)
Expand Down Expand Up @@ -914,7 +914,6 @@ func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Atta
xgb.Put32(buf[b:], Attachments[i])
b += 4
}
b = xgb.Pad(b)

return buf
}
Expand Down
2 changes: 1 addition & 1 deletion examples/randr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n",
fmt.Printf("%v, X: %d, Y: %d, Width: %d, Height: %d\n",
info.X, info.Y, info.Width, info.Height)
}

Expand Down
Loading

0 comments on commit cdbc824

Please sign in to comment.