DMX: Remove usage of alloca
Replace with heap allocations.
This commit is contained in:
parent
def6f74f2d
commit
d57060f167
48
hw/dmx/dmx.c
48
hw/dmx/dmx.c
|
@ -424,7 +424,7 @@ static int ProcDMXChangeScreensAttributes(ClientPtr client)
|
|||
|
||||
if (!_DMXXineramaActive()) goto noxinerama;
|
||||
|
||||
if (!(attribs = ALLOCATE_LOCAL(stuff->screenCount * sizeof(*attribs))))
|
||||
if (!(attribs = xalloc(stuff->screenCount * sizeof(*attribs))))
|
||||
return BadAlloc;
|
||||
|
||||
for (i = 0; i < stuff->screenCount; i++) {
|
||||
|
@ -443,7 +443,7 @@ static int ProcDMXChangeScreensAttributes(ClientPtr client)
|
|||
&errorScreen);
|
||||
#endif
|
||||
|
||||
DEALLOCATE_LOCAL(attribs);
|
||||
xfree(attribs);
|
||||
|
||||
if (status == BadValue) return status;
|
||||
|
||||
|
@ -489,7 +489,7 @@ static int ProcDMXAddScreen(ClientPtr client)
|
|||
value_list = (CARD32 *)(stuff + 1);
|
||||
count = dmxFetchScreenAttributes(stuff->valueMask, &attr, value_list);
|
||||
|
||||
if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4)))
|
||||
if (!(name = xalloc(stuff->displayNameLength + 1 + 4)))
|
||||
return BadAlloc;
|
||||
memcpy(name, &value_list[count], stuff->displayNameLength);
|
||||
name[stuff->displayNameLength] = '\0';
|
||||
|
@ -497,7 +497,7 @@ static int ProcDMXAddScreen(ClientPtr client)
|
|||
|
||||
status = dmxAttachScreen(stuff->physicalScreen, &attr);
|
||||
|
||||
DEALLOCATE_LOCAL(name);
|
||||
xfree(name);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
@ -617,30 +617,30 @@ static int ProcDMXGetWindowAttributes(ClientPtr client)
|
|||
|
||||
REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq);
|
||||
|
||||
if (!(screens = ALLOCATE_LOCAL(count * sizeof(*screens))))
|
||||
if (!(screens = xalloc(count * sizeof(*screens))))
|
||||
return BadAlloc;
|
||||
if (!(windows = ALLOCATE_LOCAL(count * sizeof(*windows)))) {
|
||||
DEALLOCATE_LOCAL(screens);
|
||||
if (!(windows = xalloc(count * sizeof(*windows)))) {
|
||||
xfree(screens);
|
||||
return BadAlloc;
|
||||
}
|
||||
if (!(pos = ALLOCATE_LOCAL(count * sizeof(*pos)))) {
|
||||
DEALLOCATE_LOCAL(windows);
|
||||
DEALLOCATE_LOCAL(screens);
|
||||
if (!(pos = xalloc(count * sizeof(*pos)))) {
|
||||
xfree(windows);
|
||||
xfree(screens);
|
||||
return BadAlloc;
|
||||
}
|
||||
if (!(vis = ALLOCATE_LOCAL(count * sizeof(*vis)))) {
|
||||
DEALLOCATE_LOCAL(pos);
|
||||
DEALLOCATE_LOCAL(windows);
|
||||
DEALLOCATE_LOCAL(screens);
|
||||
if (!(vis = xalloc(count * sizeof(*vis)))) {
|
||||
xfree(pos);
|
||||
xfree(windows);
|
||||
xfree(screens);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
if ((count = dmxPopulate(client, stuff->window, screens, windows,
|
||||
pos, vis)) < 0) {
|
||||
DEALLOCATE_LOCAL(vis);
|
||||
DEALLOCATE_LOCAL(pos);
|
||||
DEALLOCATE_LOCAL(windows);
|
||||
DEALLOCATE_LOCAL(screens);
|
||||
xfree(vis);
|
||||
xfree(pos);
|
||||
xfree(windows);
|
||||
xfree(screens);
|
||||
return BadWindow;
|
||||
}
|
||||
|
||||
|
@ -678,10 +678,10 @@ static int ProcDMXGetWindowAttributes(ClientPtr client)
|
|||
WriteToClient(client, count * sizeof(*vis), (char *)vis);
|
||||
}
|
||||
|
||||
DEALLOCATE_LOCAL(vis);
|
||||
DEALLOCATE_LOCAL(pos);
|
||||
DEALLOCATE_LOCAL(windows);
|
||||
DEALLOCATE_LOCAL(screens);
|
||||
xfree(vis);
|
||||
xfree(pos);
|
||||
xfree(windows);
|
||||
xfree(screens);
|
||||
|
||||
return client->noClientException;
|
||||
}
|
||||
|
@ -842,7 +842,7 @@ static int ProcDMXAddInput(ClientPtr client)
|
|||
value_list = (CARD32 *)(stuff + 1);
|
||||
count = dmxFetchInputAttributes(stuff->valueMask, &attr, value_list);
|
||||
|
||||
if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4)))
|
||||
if (!(name = xalloc(stuff->displayNameLength + 1 + 4)))
|
||||
return BadAlloc;
|
||||
memcpy(name, &value_list[count], stuff->displayNameLength);
|
||||
name[stuff->displayNameLength] = '\0';
|
||||
|
@ -850,7 +850,7 @@ static int ProcDMXAddInput(ClientPtr client)
|
|||
|
||||
status = dmxAddInput(&attr, &id);
|
||||
|
||||
DEALLOCATE_LOCAL(name);
|
||||
xfree(name);
|
||||
|
||||
if (status) return status;
|
||||
|
||||
|
|
|
@ -1121,9 +1121,9 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
|
|||
}
|
||||
|
||||
/* Now allocate the memory we need */
|
||||
images = ALLOCATE_LOCAL(len_images*sizeof(char));
|
||||
gids = ALLOCATE_LOCAL(glyphSet->hash.tableEntries*sizeof(Glyph));
|
||||
glyphs = ALLOCATE_LOCAL(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
|
||||
images = xalloc(len_images*sizeof(char));
|
||||
gids = xalloc(glyphSet->hash.tableEntries*sizeof(Glyph));
|
||||
glyphs = xalloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
|
||||
|
||||
memset(images, 0, len_images * sizeof(char));
|
||||
pos = images;
|
||||
|
@ -1159,9 +1159,9 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
|
|||
len_images);
|
||||
|
||||
/* Clean up */
|
||||
DEALLOCATE_LOCAL(len_images);
|
||||
DEALLOCATE_LOCAL(gids);
|
||||
DEALLOCATE_LOCAL(glyphs);
|
||||
xfree(len_images);
|
||||
xfree(gids);
|
||||
xfree(glyphs);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -531,13 +531,13 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
|
|||
/* The following only works for Render version > 0.2 */
|
||||
|
||||
/* All of the XGlyphElt* structure sizes are identical */
|
||||
elts = ALLOCATE_LOCAL(nelt * sizeof(XGlyphElt8));
|
||||
elts = xalloc(nelt * sizeof(XGlyphElt8));
|
||||
if (!elts)
|
||||
return BadAlloc;
|
||||
|
||||
glyphs = ALLOCATE_LOCAL(nglyph * size);
|
||||
glyphs = xalloc(nglyph * size);
|
||||
if (!glyphs) {
|
||||
DEALLOCATE_LOCAL(elts);
|
||||
xfree(elts);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
|
@ -605,8 +605,8 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
|
|||
|
||||
dmxSync(dmxScreen, FALSE);
|
||||
|
||||
DEALLOCATE_LOCAL(elts);
|
||||
DEALLOCATE_LOCAL(glyphs);
|
||||
xfree(elts);
|
||||
xfree(glyphs);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue