mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-01 01:04:01 +00:00
(submit/cleanup-xv-dispatch) Xext: xv: more obvious size computations in ProcXvQueryImageAttributes()
Formulate the buffer/field size computations a bit more verbose in ProcXvQueryImageAttributes(), so they're easier to understand on reading the code. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -969,7 +969,6 @@ ProcXvQueryImageAttributes(ClientPtr client)
|
||||
XvPortPtr pPort;
|
||||
int32_t *offsets;
|
||||
int32_t *pitches;
|
||||
int planeLength;
|
||||
|
||||
REQUEST(xvQueryImageAttributesReq);
|
||||
|
||||
@@ -994,7 +993,9 @@ ProcXvQueryImageAttributes(ClientPtr client)
|
||||
|
||||
num_planes = pImage->num_planes;
|
||||
|
||||
if (!(offsets = malloc(num_planes << 3)))
|
||||
// allocating for `offsets` as well as `pitches` in one block
|
||||
// both having CARD32 * num_planes (actually int32_t put into CARD32)
|
||||
if (!(offsets = malloc(num_planes * sizeof(CARD32) * 2)))
|
||||
return BadAlloc;
|
||||
pitches = offsets + num_planes;
|
||||
|
||||
@@ -1008,7 +1009,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
|
||||
rep = (xvQueryImageAttributesReply) {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = planeLength = num_planes << 1,
|
||||
.length = num_planes * 2, // in 32bit units
|
||||
.num_planes = num_planes,
|
||||
.width = width,
|
||||
.height = height,
|
||||
@@ -1017,8 +1018,8 @@ ProcXvQueryImageAttributes(ClientPtr client)
|
||||
|
||||
_WriteQueryImageAttributesReply(client, &rep);
|
||||
if (client->swapped)
|
||||
SwapLongs((CARD32 *) offsets, planeLength);
|
||||
WriteToClient(client, planeLength << 2, offsets);
|
||||
SwapLongs((CARD32 *) offsets, rep.length);
|
||||
WriteToClient(client, rep.length * sizeof(CARD32), offsets);
|
||||
|
||||
free(offsets);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user