Skip to content

Commit

Permalink
Padding on a list is on the length of the list.
Browse files Browse the repository at this point in the history
There was a bug where padding was being computed on each element of the
list. Close BurntSushi#5.
  • Loading branch information
BurntSushi committed Aug 12, 2013
1 parent 8bc7a09 commit eb7c389
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 222 deletions.
8 changes: 4 additions & 4 deletions dri2/dri2.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func AttachFormatListBytes(buf []byte, list []AttachFormat) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down Expand Up @@ -291,9 +291,9 @@ func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down
36 changes: 18 additions & 18 deletions randr/randr.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ func CrtcChangeListBytes(buf []byte, list []CrtcChange) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Mode uint32
Expand Down Expand Up @@ -453,11 +453,17 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
NotifyCrtcChange = 0
NotifyOutputChange = 1
NotifyOutputProperty = 2
)

// Notify is the event number for a NotifyEvent.
const Notify = 1

Expand Down Expand Up @@ -526,12 +532,6 @@ func init() {
xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew
}

const (
NotifyCrtcChange = 0
NotifyOutputChange = 1
NotifyOutputProperty = 2
)

// NotifyDataUnion is a represention of the NotifyDataUnion union type.
// Note that to *create* a Union, you should *never* create
// this struct directly (unless you know what you're doing).
Expand Down Expand Up @@ -809,9 +809,9 @@ func OutputChangeListBytes(buf []byte, list []OutputChange) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type OutputProperty struct {
Expand Down Expand Up @@ -889,9 +889,9 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type RefreshRates struct {
Expand Down Expand Up @@ -950,9 +950,9 @@ func RefreshRatesListBytes(buf []byte, list []RefreshRates) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values.
Expand Down Expand Up @@ -1174,9 +1174,9 @@ func ScreenSizeListBytes(buf []byte, list []ScreenSize) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down
20 changes: 10 additions & 10 deletions record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func ClientInfoListBytes(buf []byte, list []ClientInfo) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values.
Expand Down Expand Up @@ -232,9 +232,9 @@ func ExtRangeListBytes(buf []byte, list []ExtRange) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down Expand Up @@ -378,9 +378,9 @@ func RangeListBytes(buf []byte, list []Range) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Range16 struct {
Expand Down Expand Up @@ -432,9 +432,9 @@ func Range16ListBytes(buf []byte, list []Range16) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Range8 struct {
Expand Down Expand Up @@ -486,9 +486,9 @@ func Range8ListBytes(buf []byte, list []Range8) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// Skipping definition for base type 'Bool'
Expand Down
64 changes: 32 additions & 32 deletions render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Color struct {
Expand Down Expand Up @@ -154,9 +154,9 @@ func ColorListBytes(buf []byte, list []Color) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down Expand Up @@ -266,9 +266,9 @@ func DirectformatListBytes(buf []byte, list []Directformat) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Fixed int32
Expand Down Expand Up @@ -444,9 +444,9 @@ func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Glyphset uint32
Expand Down Expand Up @@ -529,9 +529,9 @@ func IndexvalueListBytes(buf []byte, list []Indexvalue) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Linefix struct {
Expand Down Expand Up @@ -589,9 +589,9 @@ func LinefixListBytes(buf []byte, list []Linefix) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// BadPictFormat is the error number for a BadPictFormat.
Expand Down Expand Up @@ -812,9 +812,9 @@ func PictdepthListBytes(buf []byte, list []Pictdepth) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// PictdepthListSize computes the size (bytes) of a list of Pictdepth values.
Expand Down Expand Up @@ -914,9 +914,9 @@ func PictforminfoListBytes(buf []byte, list []Pictforminfo) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Pictscreen struct {
Expand Down Expand Up @@ -974,9 +974,9 @@ func PictscreenListBytes(buf []byte, list []Pictscreen) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// PictscreenListSize computes the size (bytes) of a list of Pictscreen values.
Expand Down Expand Up @@ -1097,9 +1097,9 @@ func PictvisualListBytes(buf []byte, list []Pictvisual) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Pointfix struct {
Expand Down Expand Up @@ -1151,9 +1151,9 @@ func PointfixListBytes(buf []byte, list []Pointfix) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down Expand Up @@ -1229,9 +1229,9 @@ func SpanfixListBytes(buf []byte, list []Spanfix) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

const (
Expand Down Expand Up @@ -1341,9 +1341,9 @@ func TransformListBytes(buf []byte, list []Transform) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Trap struct {
Expand Down Expand Up @@ -1401,9 +1401,9 @@ func TrapListBytes(buf []byte, list []Trap) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Trapezoid struct {
Expand Down Expand Up @@ -1475,9 +1475,9 @@ func TrapezoidListBytes(buf []byte, list []Trapezoid) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Triangle struct {
Expand Down Expand Up @@ -1545,9 +1545,9 @@ func TriangleListBytes(buf []byte, list []Triangle) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// Skipping definition for base type 'Bool'
Expand Down
8 changes: 4 additions & 4 deletions res/res.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func ClientListBytes(buf []byte, list []Client) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

type Type struct {
Expand Down Expand Up @@ -140,9 +140,9 @@ func TypeListBytes(buf []byte, list []Type) int {
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += xgb.Pad(len(structBytes))
b += len(structBytes)
}
return b
return xgb.Pad(b)
}

// Skipping definition for base type 'Bool'
Expand Down
Loading

0 comments on commit eb7c389

Please sign in to comment.