On Wed, Nov 16, 2011 at 1:54 PM, Jamey Sharp <ja...@minilop.net> wrote: > On Wed, Nov 16, 2011 at 02:36:45PM +0100, walter harms wrote: >> Am 15.11.2011 23:49, schrieb Rob Clark: >> > + nformats = (rep.length / sizeof(*formats)) * 4; >> > + formats = malloc(nformats * sizeof(*formats)); >> >> i do not understand the 4 here. do you mean: >> (rep.length / sizeof(*formats))*sizeof(*formats) > > In the X protocol, the length field is always measured in 4-byte units. > > I'm guessing instead that you meant: > nformats = rep.length * 4 / sizeof(*formats); > > I think doing the division first will get the wrong answer any time the > number of formats is not divisible by 4, right?
ahh, yes, you are correct, the multiplication should be before the divide.. I realized by coincidence I had 8 formats. I'll fix that BR, -R > Jamey > > _______________________________________________ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: http://lists.x.org/mailman/listinfo/xorg-devel > _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel