aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/dmx/glxProxy/glxcmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/dmx/glxProxy/glxcmds.c')
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxcmds.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c
index 4c500c93d..ddcb98135 100644
--- a/xorg-server/hw/dmx/glxProxy/glxcmds.c
+++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c
@@ -284,11 +284,11 @@ CreateContext(__GLXclientState * cl,
* allocate memory for back-end servers info
*/
num_be_screens = to_screen - from_screen + 1;
- glxc->real_ids = (XID *) malloc(sizeof(XID) * num_be_screens);
+ glxc->real_ids = xallocarray(num_be_screens, sizeof(XID));
if (!glxc->real_ids) {
return BadAlloc;
}
- glxc->real_vids = (XID *) malloc(sizeof(XID) * num_be_screens);
+ glxc->real_vids = xallocarray(num_be_screens, sizeof(XID));
if (!glxc->real_vids) {
return BadAlloc;
}
@@ -685,22 +685,16 @@ AddCurrentContext(__GLXclientState * cl, __GLXcontext * glxc, DrawablePtr pDraw)
if (!num) {
table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
- cl->be_currentCTag =
- (GLXContextTag *) malloc(screenInfo.numScreens *
- sizeof(GLXContextTag));
+ cl->be_currentCTag = xallocarray(screenInfo.numScreens,
+ sizeof(GLXContextTag));
}
else {
- table = (__GLXcontext **) realloc(table,
- (num + 1) * sizeof(__GLXcontext *));
- cl->currentDrawables = (DrawablePtr *) realloc(cl->currentDrawables,
- (num +
- 1) *
- sizeof(DrawablePtr));
- cl->be_currentCTag =
- (GLXContextTag *) realloc(cl->be_currentCTag,
- (num +
- 1) * screenInfo.numScreens *
- sizeof(GLXContextTag));
+ table = reallocarray(table, num + 1, sizeof(__GLXcontext *));
+ cl->currentDrawables = reallocarray(cl->currentDrawables, num + 1,
+ sizeof(DrawablePtr));
+ cl->be_currentCTag = reallocarray(cl->be_currentCTag,
+ (num + 1) * screenInfo.numScreens,
+ sizeof(GLXContextTag));
}
table[num] = glxc;
cl->currentDrawables[num] = pDraw;
@@ -1896,7 +1890,7 @@ CreateGLXPixmap(__GLXclientState * cl,
if (!pGlxPixmap) {
return BadAlloc;
}
- pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
+ pGlxPixmap->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID));
if (!pGlxPixmap->be_xids) {
free(pGlxPixmap);
return BadAlloc;
@@ -3356,7 +3350,7 @@ __glXCreatePbuffer(__GLXclientState * cl, GLbyte * pc)
return BadAlloc;
}
- pGlxPbuffer->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
+ pGlxPbuffer->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID));
if (!pGlxPbuffer->be_xids) {
free(pGlxPbuffer);
return BadAlloc;
@@ -3617,13 +3611,13 @@ __glXGetDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
}
if (reply.numAttribs) {
- attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
- attribs = (CARD32 *) malloc(attribs_size);
+ attribs = xallocarray(reply.numAttribs, 2 * __GLX_SIZE_CARD32);
if (attribs == NULL) {
UnlockDisplay(dpy);
SyncHandle();
return BadAlloc;
}
+ attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
_XRead(dpy, (char *) attribs, attribs_size);
}