Remove Xcalloc/Xmalloc/Xfree calls

These calls allowed Xlib to use a custom memory allocator, but Xlib has
used the standard C library functions since at least its initial import
into git in 2003. It seems unlikely that it will grow a custom memory
allocator. The functions now just add extra overhead. Replacing them
will make future Coccinelle patches simpler.

This patch has been generated by the following Coccinelle semantic
patch:

// Remove Xcalloc/Xmalloc/Xfree calls

@@ expression E1, E2; @@
- Xcalloc (E1, E2)
+ calloc (E1, E2)

@@ expression E; @@
- Xmalloc (E)
+ malloc (E)

@@ expression E; @@
- Xfree (E)
+ free (E)

@@ expression E; @@
- XFree (E)
+ free (E)

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Matt Turner
2012-09-04 22:52:36 -07:00
parent 17a574d7cd
commit 7c7b7b068b
31 changed files with 191 additions and 192 deletions

View File

@@ -656,9 +656,9 @@ GLX_eglTerminate(_EGLDriver *drv, _EGLDisplay *disp)
_eglCleanupDisplay(disp); _eglCleanupDisplay(disp);
if (GLX_dpy->visuals) if (GLX_dpy->visuals)
XFree(GLX_dpy->visuals); free(GLX_dpy->visuals);
if (GLX_dpy->fbconfigs) if (GLX_dpy->fbconfigs)
XFree(GLX_dpy->fbconfigs); free(GLX_dpy->fbconfigs);
if (!disp->PlatformDisplay) if (!disp->PlatformDisplay)
XCloseDisplay(GLX_dpy->dpy); XCloseDisplay(GLX_dpy->dpy);
@@ -909,7 +909,7 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp,
if (vinfo) { if (vinfo) {
GLX_surf->glx_drawable = GLX_drv->glXCreateGLXPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable = GLX_drv->glXCreateGLXPixmap(GLX_dpy->dpy,
vinfo, GLX_surf->drawable); vinfo, GLX_surf->drawable);
XFree(vinfo); free(vinfo);
} }
} }
else { else {

View File

@@ -85,7 +85,7 @@ _gl_context_modes_destroy(__GLcontextModes * modes)
while (modes != NULL) { while (modes != NULL) {
__GLcontextModes *const next = modes->next; __GLcontextModes *const next = modes->next;
Xfree(modes); free(modes);
modes = next; modes = next;
} }
} }
@@ -101,7 +101,7 @@ _gl_context_modes_create(unsigned count, size_t minimum_size)
next = &base; next = &base;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
*next = (__GLcontextModes *) Xmalloc(size); *next = (__GLcontextModes *) malloc(size);
if (*next == NULL) { if (*next == NULL) {
_gl_context_modes_destroy(base); _gl_context_modes_destroy(base);
base = NULL; base = NULL;
@@ -165,7 +165,7 @@ __glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
length = reply.length * 4; length = reply.length * 4;
numbytes = reply.size; numbytes = reply.size;
buf = (char *) Xmalloc(numbytes); buf = (char *) malloc(numbytes);
if (buf != NULL) { if (buf != NULL) {
_XRead(dpy, buf, numbytes); _XRead(dpy, buf, numbytes);
length -= numbytes; length -= numbytes;
@@ -200,9 +200,9 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
_gl_context_modes_destroy(psc->configs); _gl_context_modes_destroy(psc->configs);
psc->configs = NULL; /* NOTE: just for paranoia */ psc->configs = NULL; /* NOTE: just for paranoia */
} }
Xfree((char *) psc->serverGLXexts); free((char *) psc->serverGLXexts);
} }
XFree((char *) priv->screenConfigs); free((char *) priv->screenConfigs);
priv->screenConfigs = NULL; priv->screenConfigs = NULL;
} }
@@ -218,9 +218,9 @@ __glXFreeDisplayPrivate(XExtData * extension)
priv = (__GLXdisplayPrivate *) extension->private_data; priv = (__GLXdisplayPrivate *) extension->private_data;
FreeScreenConfigs(priv); FreeScreenConfigs(priv);
if (priv->serverGLXversion) if (priv->serverGLXversion)
Xfree((char *) priv->serverGLXversion); free((char *) priv->serverGLXversion);
Xfree((char *) priv); free((char *) priv);
return 0; return 0;
} }
@@ -491,7 +491,7 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
if (prop_size <= sizeof(buf)) if (prop_size <= sizeof(buf))
props = buf; props = buf;
else else
props = Xmalloc(prop_size); props = malloc(prop_size);
/* Read each config structure and convert it into our format */ /* Read each config structure and convert it into our format */
m = modes; m = modes;
@@ -506,7 +506,7 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
} }
if (props != buf) if (props != buf)
Xfree(props); free(props);
return modes; return modes;
} }
@@ -568,7 +568,7 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
** First allocate memory for the array of per screen configs. ** First allocate memory for the array of per screen configs.
*/ */
screens = ScreenCount(dpy); screens = ScreenCount(dpy);
priv->screenConfigs = Xmalloc(screens * sizeof *priv->screenConfigs); priv->screenConfigs = malloc(screens * sizeof *priv->screenConfigs);
if (!priv->screenConfigs) { if (!priv->screenConfigs) {
return GL_FALSE; return GL_FALSE;
} }
@@ -581,7 +581,7 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
} }
for (i = 0; i < screens; i++) { for (i = 0; i < screens; i++) {
psc = Xcalloc(1, sizeof *psc); psc = calloc(1, sizeof *psc);
if (!psc) if (!psc)
return GL_FALSE; return GL_FALSE;
getFBConfigs(psc, priv, i); getFBConfigs(psc, priv, i);
@@ -619,12 +619,12 @@ __glXInitialize(Display * dpy)
/* /*
** Allocate memory for all the pieces needed for this buffer. ** Allocate memory for all the pieces needed for this buffer.
*/ */
private = (XExtData *) Xmalloc(sizeof(XExtData)); private = (XExtData *) malloc(sizeof(XExtData));
if (!private) if (!private)
return NULL; return NULL;
dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); dpyPriv = (__GLXdisplayPrivate *) calloc(1, sizeof(__GLXdisplayPrivate));
if (!dpyPriv) { if (!dpyPriv) {
Xfree(private); free(private);
return NULL; return NULL;
} }
@@ -636,8 +636,8 @@ __glXInitialize(Display * dpy)
dpyPriv->dpy = dpy; dpyPriv->dpy = dpy;
if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
Xfree(dpyPriv); free(dpyPriv);
Xfree(private); free(private);
return NULL; return NULL;
} }

View File

@@ -96,9 +96,9 @@ x11_screen_destroy(struct x11_screen *xscr)
if (xscr->dri_fd >= 0) if (xscr->dri_fd >= 0)
close(xscr->dri_fd); close(xscr->dri_fd);
if (xscr->dri_driver) if (xscr->dri_driver)
Xfree(xscr->dri_driver); free(xscr->dri_driver);
if (xscr->dri_device) if (xscr->dri_device)
Xfree(xscr->dri_device); free(xscr->dri_device);
#ifdef GLX_DIRECT_RENDERING #ifdef GLX_DIRECT_RENDERING
/* xscr->glx_dpy will be destroyed with the X display */ /* xscr->glx_dpy will be destroyed with the X display */
@@ -107,7 +107,7 @@ x11_screen_destroy(struct x11_screen *xscr)
#endif #endif
if (xscr->visuals) if (xscr->visuals)
XFree(xscr->visuals); free(xscr->visuals);
FREE(xscr); FREE(xscr);
} }

View File

@@ -409,7 +409,7 @@ get_visual( Display *dpy, int scr, unsigned int depth, int xclass )
return vis; return vis;
} }
else { else {
XFree((void *) vis); free((void *) vis);
return NULL; return NULL;
} }
} }

View File

@@ -113,7 +113,7 @@ static Status Validate(Display *dpy, XvPortID port, int surface_type_id,
*mc_type, *surface_flags, *subpic_max_w, *subpic_max_h); *mc_type, *surface_flags, *subpic_max_w, *subpic_max_h);
} }
XFree(surface_info); free(surface_info);
} }
} }

View File

@@ -116,7 +116,7 @@ static Status Validate(Display *dpy, XvPortID port, int surface_type_id, int xvi
subpictures = XvMCListSubpictureTypes(dpy, port, surface_type_id, &num_subpics); subpictures = XvMCListSubpictureTypes(dpy, port, surface_type_id, &num_subpics);
if (num_subpics < 1) { if (num_subpics < 1) {
if (subpictures) if (subpictures)
XFree(subpictures); free(subpictures);
return BadMatch; return BadMatch;
} }
if (!subpictures) if (!subpictures)
@@ -161,7 +161,7 @@ static Status Validate(Display *dpy, XvPortID port, int surface_type_id, int xvi
} }
} }
XFree(subpictures); free(subpictures);
return i < num_subpics ? Success : BadMatch; return i < num_subpics ? Success : BadMatch;
} }

View File

@@ -174,7 +174,7 @@ int main(int argc, char **argv)
assert(XvMCDestroyContext(display, &context) == Success); assert(XvMCDestroyContext(display, &context) == Success);
XFree(subpics); free(subpics);
XvUngrabPort(display, port_num, CurrentTime); XvUngrabPort(display, port_num, CurrentTime);
XCloseDisplay(display); XCloseDisplay(display);

View File

@@ -102,7 +102,7 @@ int GetPort
} }
} }
XFree(surface_info); free(surface_info);
} }
} }
} }

View File

@@ -147,7 +147,7 @@ graw_create_window_and_screen( int x,
if (screen == NULL) if (screen == NULL)
goto fail; goto fail;
XFree(visinfo); free(visinfo);
return screen; return screen;
fail: fail:
@@ -158,7 +158,7 @@ fail:
FREE(xlib_handle); FREE(xlib_handle);
if (visinfo) if (visinfo)
XFree(visinfo); free(visinfo);
if (win) if (win)
XDestroyWindow(graw.display, win); XDestroyWindow(graw.display, win);

View File

@@ -201,7 +201,7 @@ XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
} }
if (rep.length) { if (rep.length) {
if (!(*busIdString = (char *) Xcalloc(rep.busIdStringLength + 1, 1))) { if (!(*busIdString = (char *) calloc(rep.busIdStringLength + 1, 1))) {
_XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3));
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
@@ -302,7 +302,7 @@ XF86DRIGetClientDriverName(Display * dpy, int screen,
if (rep.length) { if (rep.length) {
if (! if (!
(*clientDriverName = (*clientDriverName =
(char *) Xcalloc(rep.clientDriverNameLength + 1, 1))) { (char *) calloc(rep.clientDriverNameLength + 1, 1))) {
_XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3));
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
@@ -521,7 +521,7 @@ XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
if (*numClipRects) { if (*numClipRects) {
int len = sizeof(drm_clip_rect_t) * (*numClipRects); int len = sizeof(drm_clip_rect_t) * (*numClipRects);
*pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); *pClipRects = (drm_clip_rect_t *) calloc(len, 1);
if (*pClipRects) if (*pClipRects)
_XRead(dpy, (char *) *pClipRects, len); _XRead(dpy, (char *) *pClipRects, len);
} }
@@ -532,7 +532,7 @@ XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
if (*numBackClipRects) { if (*numBackClipRects) {
int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
*pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); *pBackClipRects = (drm_clip_rect_t *) calloc(len, 1);
if (*pBackClipRects) if (*pBackClipRects)
_XRead(dpy, (char *) *pBackClipRects, len); _XRead(dpy, (char *) *pBackClipRects, len);
} }
@@ -582,7 +582,7 @@ XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer,
*devPrivateSize = rep.devPrivateSize; *devPrivateSize = rep.devPrivateSize;
if (rep.length) { if (rep.length) {
if (!(*pDevPrivate = (void *) Xcalloc(rep.devPrivateSize, 1))) { if (!(*pDevPrivate = (void *) calloc(rep.devPrivateSize, 1))) {
_XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3));
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();

View File

@@ -79,7 +79,7 @@ __glXReadPixelReply(Display * dpy, struct glx_context * gc, unsigned max_dim,
size = reply.length * 4; size = reply.length * 4;
if (size != 0) { if (size != 0) {
void *buf = Xmalloc(size); void *buf = malloc(size);
if (buf == NULL) { if (buf == NULL) {
_XEatData(dpy, size); _XEatData(dpy, size);
@@ -94,7 +94,7 @@ __glXReadPixelReply(Display * dpy, struct glx_context * gc, unsigned max_dim,
} }
__glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest); __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
Xfree(buf); free(buf);
} }
} }
} }

View File

@@ -134,12 +134,12 @@ applegl_create_context(struct glx_screen *psc,
/* TODO: Integrate this with apple_glx_create_context and make /* TODO: Integrate this with apple_glx_create_context and make
* struct apple_glx_context inherit from struct glx_context. */ * struct apple_glx_context inherit from struct glx_context. */
gc = Xcalloc(1, sizeof (*gc)); gc = calloc(1, sizeof(*gc));
if (gc == NULL) if (gc == NULL)
return NULL; return NULL;
if (!glx_context_init(gc, psc, config)) { if (!glx_context_init(gc, psc, config)) {
Xfree(gc); free(gc);
return NULL; return NULL;
} }
@@ -173,7 +173,7 @@ applegl_create_screen(int screen, struct glx_display * priv)
{ {
struct glx_screen *psc; struct glx_screen *psc;
psc = Xmalloc(sizeof *psc); psc = malloc(sizeof *psc);
if (psc == NULL) if (psc == NULL)
return NULL; return NULL;

View File

@@ -75,7 +75,7 @@ __indirect_glPushClientAttrib(GLuint mask)
if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) { if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
if (!(sp = *spp)) { if (!(sp = *spp)) {
sp = (__GLXattribute *) Xmalloc(sizeof(__GLXattribute)); sp = (__GLXattribute *) malloc(sizeof(__GLXattribute));
*spp = sp; *spp = sp;
} }
sp->mask = mask; sp->mask = mask;
@@ -135,7 +135,7 @@ __glFreeAttributeState(struct glx_context * gc)
spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) { spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) {
sp = *spp; sp = *spp;
if (sp) { if (sp) {
XFree((char *) sp); free((char *) sp);
} }
else { else {
break; break;

View File

@@ -152,5 +152,5 @@ __glX_send_client_info(struct glx_display *glx_dpy)
gl_extension_string); gl_extension_string);
} }
Xfree(gl_extension_string); free(gl_extension_string);
} }

View File

@@ -303,7 +303,7 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
return False; return False;
} }
*driverName = Xmalloc(rep.driverNameLength + 1); *driverName = malloc(rep.driverNameLength + 1);
if (*driverName == NULL) { if (*driverName == NULL) {
_XEatData(dpy, _XEatData(dpy,
((rep.driverNameLength + 3) & ~3) + ((rep.driverNameLength + 3) & ~3) +
@@ -315,9 +315,9 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
_XReadPad(dpy, *driverName, rep.driverNameLength); _XReadPad(dpy, *driverName, rep.driverNameLength);
(*driverName)[rep.driverNameLength] = '\0'; (*driverName)[rep.driverNameLength] = '\0';
*deviceName = Xmalloc(rep.deviceNameLength + 1); *deviceName = malloc(rep.deviceNameLength + 1);
if (*deviceName == NULL) { if (*deviceName == NULL) {
Xfree(*driverName); free(*driverName);
_XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
@@ -431,7 +431,7 @@ DRI2GetBuffers(Display * dpy, XID drawable,
*height = rep.height; *height = rep.height;
*outCount = rep.count; *outCount = rep.count;
buffers = Xmalloc(rep.count * sizeof buffers[0]); buffers = malloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) { if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer); _XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy); UnlockDisplay(dpy);
@@ -490,7 +490,7 @@ DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
*height = rep.height; *height = rep.height;
*outCount = rep.count; *outCount = rep.count;
buffers = Xmalloc(rep.count * sizeof buffers[0]); buffers = malloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) { if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer); _XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy); UnlockDisplay(dpy);

View File

@@ -127,11 +127,11 @@ dri2_destroy_context(struct glx_context *context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) if (context->extensions)
XFree((char *) context->extensions); free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp); free(pcp);
} }
static Bool static Bool
@@ -199,13 +199,13 @@ dri2_create_context(struct glx_screen *base,
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
pcp = Xmalloc(sizeof *pcp); pcp = malloc(sizeof *pcp);
if (pcp == NULL) if (pcp == NULL)
return NULL; return NULL;
memset(pcp, 0, sizeof *pcp); memset(pcp, 0, sizeof *pcp);
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -214,7 +214,7 @@ dri2_create_context(struct glx_screen *base,
config->driConfig, shared, pcp); config->driConfig, shared, pcp);
if (pcp->driContext == NULL) { if (pcp->driContext == NULL) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -262,7 +262,7 @@ dri2_create_context_attribs(struct glx_screen *base,
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
pcp = Xmalloc(sizeof *pcp); pcp = malloc(sizeof *pcp);
if (pcp == NULL) { if (pcp == NULL) {
*error = __DRI_CTX_ERROR_NO_MEMORY; *error = __DRI_CTX_ERROR_NO_MEMORY;
goto error_exit; goto error_exit;
@@ -314,7 +314,7 @@ dri2_create_context_attribs(struct glx_screen *base,
error_exit: error_exit:
if (pcp != NULL) if (pcp != NULL)
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -340,7 +340,7 @@ dri2DestroyDrawable(__GLXDRIdrawable *base)
if (pdraw->base.xDrawable != pdraw->base.drawable) if (pdraw->base.xDrawable != pdraw->base.drawable)
DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable); DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable);
Xfree(pdraw); free(pdraw);
} }
static __GLXDRIdrawable * static __GLXDRIdrawable *
@@ -354,7 +354,7 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
struct dri2_display *pdp; struct dri2_display *pdp;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
pdraw = Xmalloc(sizeof(*pdraw)); pdraw = malloc(sizeof(*pdraw));
if (!pdraw) if (!pdraw)
return NULL; return NULL;
@@ -394,14 +394,14 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
if (!pdraw->driDrawable) { if (!pdraw->driDrawable) {
DRI2DestroyDrawable(psc->base.dpy, xDrawable); DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw); free(pdraw);
return NULL; return NULL;
} }
if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) { if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
(*psc->core->destroyDrawable) (pdraw->driDrawable); (*psc->core->destroyDrawable) (pdraw->driDrawable);
DRI2DestroyDrawable(psc->base.dpy, xDrawable); DRI2DestroyDrawable(psc->base.dpy, xDrawable);
Xfree(pdraw); free(pdraw);
return None; return None;
} }
@@ -633,7 +633,7 @@ dri2DestroyScreen(struct glx_screen *base)
(*psc->core->destroyScreen) (psc->driScreen); (*psc->core->destroyScreen) (psc->driScreen);
driDestroyConfigs(psc->driver_configs); driDestroyConfigs(psc->driver_configs);
close(psc->fd); close(psc->fd);
Xfree(psc); free(psc);
} }
/** /**
@@ -765,7 +765,7 @@ dri2GetBuffers(__DRIdrawable * driDrawable,
pdraw->height = *height; pdraw->height = *height;
process_buffers(pdraw, buffers, *out_count); process_buffers(pdraw, buffers, *out_count);
Xfree(buffers); free(buffers);
return pdraw->buffers; return pdraw->buffers;
} }
@@ -790,7 +790,7 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
pdraw->height = *height; pdraw->height = *height;
process_buffers(pdraw, buffers, *out_count); process_buffers(pdraw, buffers, *out_count);
Xfree(buffers); free(buffers);
return pdraw->buffers; return pdraw->buffers;
} }
@@ -1020,7 +1020,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
drm_magic_t magic; drm_magic_t magic;
int i; int i;
psc = Xmalloc(sizeof *psc); psc = malloc(sizeof *psc);
if (psc == NULL) if (psc == NULL)
return NULL; return NULL;
@@ -1028,14 +1028,14 @@ dri2CreateScreen(int screen, struct glx_display * priv)
psc->fd = -1; psc->fd = -1;
if (!glx_screen_init(&psc->base, screen, priv)) { if (!glx_screen_init(&psc->base, screen, priv)) {
Xfree(psc); free(psc);
return NULL; return NULL;
} }
if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen), if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen),
&driverName, &deviceName)) { &driverName, &deviceName)) {
glx_screen_cleanup(&psc->base); glx_screen_cleanup(&psc->base);
XFree(psc); free(psc);
InfoMessageF("screen %d does not appear to be DRI2 capable\n", screen); InfoMessageF("screen %d does not appear to be DRI2 capable\n", screen);
return NULL; return NULL;
} }
@@ -1153,8 +1153,8 @@ dri2CreateScreen(int screen, struct glx_display * priv)
psp->copySubBuffer = dri2CopySubBuffer; psp->copySubBuffer = dri2CopySubBuffer;
__glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer"); __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
Xfree(driverName); free(driverName);
Xfree(deviceName); free(deviceName);
tmp = getenv("LIBGL_SHOW_FPS"); tmp = getenv("LIBGL_SHOW_FPS");
psc->show_fps = tmp && strcmp(tmp, "1") == 0; psc->show_fps = tmp && strcmp(tmp, "1") == 0;
@@ -1176,10 +1176,10 @@ handle_error:
if (psc->driver) if (psc->driver)
dlclose(psc->driver); dlclose(psc->driver);
Xfree(driverName); free(driverName);
Xfree(deviceName); free(deviceName);
glx_screen_cleanup(&psc->base); glx_screen_cleanup(&psc->base);
XFree(psc); free(psc);
return NULL; return NULL;
} }
@@ -1192,7 +1192,7 @@ dri2DestroyDisplay(__GLXDRIdisplay * dpy)
struct dri2_display *pdp = (struct dri2_display *) dpy; struct dri2_display *pdp = (struct dri2_display *) dpy;
__glxHashDestroy(pdp->dri2Hash); __glxHashDestroy(pdp->dri2Hash);
Xfree(dpy); free(dpy);
} }
_X_HIDDEN __GLXDRIdrawable * _X_HIDDEN __GLXDRIdrawable *
@@ -1222,12 +1222,12 @@ dri2CreateDisplay(Display * dpy)
if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
return NULL; return NULL;
pdp = Xmalloc(sizeof *pdp); pdp = malloc(sizeof *pdp);
if (pdp == NULL) if (pdp == NULL)
return NULL; return NULL;
if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) { if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) {
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }
@@ -1253,7 +1253,7 @@ dri2CreateDisplay(Display * dpy)
pdp->dri2Hash = __glxHashCreate(); pdp->dri2Hash = __glxHashCreate();
if (pdp->dri2Hash == NULL) { if (pdp->dri2Hash == NULL) {
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }

View File

@@ -340,7 +340,7 @@ createDriMode(const __DRIcoreExtension * core,
if (driConfigs[i] == NULL) if (driConfigs[i] == NULL)
return NULL; return NULL;
driConfig = Xmalloc(sizeof *driConfig); driConfig = malloc(sizeof *driConfig);
if (driConfig == NULL) if (driConfig == NULL)
return NULL; return NULL;

View File

@@ -136,7 +136,7 @@ driGetDriverName(Display * dpy, int scrNum, char **driverName)
Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev); Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev);
if (ret) if (ret)
Xfree(dev); free(dev);
return ret; return ret;
} }
@@ -163,7 +163,7 @@ glXGetScreenDriver(Display * dpy, int scrNum)
if (len >= 31) if (len >= 31)
return NULL; return NULL;
memcpy(ret, driverName, len + 1); memcpy(ret, driverName, len + 1);
Xfree(driverName); free(driverName);
return ret; return ret;
} }
return NULL; return NULL;
@@ -354,7 +354,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
fd = drmOpenOnce(NULL, BusID, &newlyopened); fd = drmOpenOnce(NULL, BusID, &newlyopened);
Xfree(BusID); /* No longer needed */ free(BusID); /* No longer needed */
if (fd < 0) { if (fd < 0) {
ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd)); ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd));
@@ -395,7 +395,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
goto handle_error; goto handle_error;
} }
Xfree(driverName); /* No longer needed. */ free(driverName); /* No longer needed. */
/* /*
* Get device-specific info. pDevPriv will point to a struct * Get device-specific info. pDevPriv will point to a struct
@@ -477,7 +477,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn)) if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn))
visual->visualRating = GLX_NON_CONFORMANT_CONFIG; visual->visualRating = GLX_NON_CONFORMANT_CONFIG;
XFree(visuals); free(visuals);
} }
} }
@@ -496,7 +496,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
drmUnmap((drmAddress) framebuffer.base, framebuffer.size); drmUnmap((drmAddress) framebuffer.base, framebuffer.size);
if (framebuffer.dev_priv != NULL) if (framebuffer.dev_priv != NULL)
Xfree(framebuffer.dev_priv); free(framebuffer.dev_priv);
if (fd >= 0) if (fd >= 0)
drmCloseOnce(fd); drmCloseOnce(fd);
@@ -517,12 +517,12 @@ dri_destroy_context(struct glx_context * context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) if (context->extensions)
XFree((char *) context->extensions); free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);
XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID); XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp); free(pcp);
} }
static int static int
@@ -595,20 +595,20 @@ dri_create_context(struct glx_screen *base,
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
pcp = Xmalloc(sizeof *pcp); pcp = malloc(sizeof *pcp);
if (pcp == NULL) if (pcp == NULL)
return NULL; return NULL;
memset(pcp, 0, sizeof *pcp); memset(pcp, 0, sizeof *pcp);
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr, if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr,
config->base.visualID, config->base.visualID,
&pcp->hwContextID, &hwContext)) { &pcp->hwContextID, &hwContext)) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -618,7 +618,7 @@ dri_create_context(struct glx_screen *base,
renderType, shared, hwContext, pcp); renderType, shared, hwContext, pcp);
if (pcp->driContext == NULL) { if (pcp->driContext == NULL) {
XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID); XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -635,7 +635,7 @@ driDestroyDrawable(__GLXDRIdrawable * pdraw)
(*psc->core->destroyDrawable) (pdp->driDrawable); (*psc->core->destroyDrawable) (pdp->driDrawable);
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable); XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable);
Xfree(pdraw); free(pdraw);
} }
static __GLXDRIdrawable * static __GLXDRIdrawable *
@@ -653,7 +653,7 @@ driCreateDrawable(struct glx_screen *base,
if (xDrawable != drawable) if (xDrawable != drawable)
return NULL; return NULL;
pdp = Xmalloc(sizeof *pdp); pdp = malloc(sizeof *pdp);
if (!pdp) if (!pdp)
return NULL; return NULL;
@@ -663,7 +663,7 @@ driCreateDrawable(struct glx_screen *base,
if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr, if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr,
drawable, &hwDrawable)) { drawable, &hwDrawable)) {
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }
@@ -677,7 +677,7 @@ driCreateDrawable(struct glx_screen *base,
if (!pdp->driDrawable) { if (!pdp->driDrawable) {
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable); XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable);
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }
@@ -850,13 +850,13 @@ driCreateScreen(int screen, struct glx_display *priv)
char *driverName; char *driverName;
int i; int i;
psc = Xcalloc(1, sizeof *psc); psc = calloc(1, sizeof *psc);
if (psc == NULL) if (psc == NULL)
return NULL; return NULL;
memset(psc, 0, sizeof *psc); memset(psc, 0, sizeof *psc);
if (!glx_screen_init(&psc->base, screen, priv)) { if (!glx_screen_init(&psc->base, screen, priv)) {
Xfree(psc); free(psc);
return NULL; return NULL;
} }
@@ -865,7 +865,7 @@ driCreateScreen(int screen, struct glx_display *priv)
} }
psc->driver = driOpenDriver(driverName); psc->driver = driOpenDriver(driverName);
Xfree(driverName); free(driverName);
if (psc->driver == NULL) if (psc->driver == NULL)
goto cleanup; goto cleanup;
@@ -921,7 +921,7 @@ cleanup:
if (psc->driver) if (psc->driver)
dlclose(psc->driver); dlclose(psc->driver);
glx_screen_cleanup(&psc->base); glx_screen_cleanup(&psc->base);
Xfree(psc); free(psc);
return NULL; return NULL;
} }
@@ -931,7 +931,7 @@ cleanup:
static void static void
driDestroyDisplay(__GLXDRIdisplay * dpy) driDestroyDisplay(__GLXDRIdisplay * dpy)
{ {
Xfree(dpy); free(dpy);
} }
/* /*
@@ -954,7 +954,7 @@ driCreateDisplay(Display * dpy)
return NULL; return NULL;
} }
pdpyp = Xmalloc(sizeof *pdpyp); pdpyp = malloc(sizeof *pdpyp);
if (!pdpyp) { if (!pdpyp) {
return NULL; return NULL;
} }

View File

@@ -118,7 +118,7 @@ static void
XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable) XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable)
{ {
XDestroyImage(pdp->ximage); XDestroyImage(pdp->ximage);
XFree(pdp->visinfo); free(pdp->visinfo);
XFreeGC(dpy, pdp->gc); XFreeGC(dpy, pdp->gc);
XFreeGC(dpy, pdp->swapgc); XFreeGC(dpy, pdp->swapgc);
@@ -256,11 +256,11 @@ drisw_destroy_context(struct glx_context *context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) if (context->extensions)
XFree((char *) context->extensions); free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);
Xfree(pcp); free(pcp);
} }
static int static int
@@ -393,13 +393,13 @@ drisw_create_context(struct glx_screen *base,
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
pcp = Xmalloc(sizeof *pcp); pcp = malloc(sizeof *pcp);
if (pcp == NULL) if (pcp == NULL)
return NULL; return NULL;
memset(pcp, 0, sizeof *pcp); memset(pcp, 0, sizeof *pcp);
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -407,7 +407,7 @@ drisw_create_context(struct glx_screen *base,
(*psc->core->createNewContext) (psc->driScreen, (*psc->core->createNewContext) (psc->driScreen,
config->driConfig, shared, pcp); config->driConfig, shared, pcp);
if (pcp->driContext == NULL) { if (pcp->driContext == NULL) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -458,13 +458,13 @@ drisw_create_context_attribs(struct glx_screen *base,
shared = pcp_shared->driContext; shared = pcp_shared->driContext;
} }
pcp = Xmalloc(sizeof *pcp); pcp = malloc(sizeof *pcp);
if (pcp == NULL) if (pcp == NULL)
return NULL; return NULL;
memset(pcp, 0, sizeof *pcp); memset(pcp, 0, sizeof *pcp);
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -492,7 +492,7 @@ drisw_create_context_attribs(struct glx_screen *base,
error, error,
pcp); pcp);
if (pcp->driContext == NULL) { if (pcp->driContext == NULL) {
Xfree(pcp); free(pcp);
return NULL; return NULL;
} }
@@ -510,7 +510,7 @@ driswDestroyDrawable(__GLXDRIdrawable * pdraw)
(*psc->core->destroyDrawable) (pdp->driDrawable); (*psc->core->destroyDrawable) (pdp->driDrawable);
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable); XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
Xfree(pdp); free(pdp);
} }
static __GLXDRIdrawable * static __GLXDRIdrawable *
@@ -523,7 +523,7 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
Bool ret; Bool ret;
const __DRIswrastExtension *swrast = psc->swrast; const __DRIswrastExtension *swrast = psc->swrast;
pdp = Xmalloc(sizeof(*pdp)); pdp = malloc(sizeof(*pdp));
if (!pdp) if (!pdp)
return NULL; return NULL;
@@ -534,7 +534,7 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID); ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
if (!ret) { if (!ret) {
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }
@@ -544,7 +544,7 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
if (!pdp->driDrawable) { if (!pdp->driDrawable) {
XDestroyDrawable(pdp, psc->base.dpy, xDrawable); XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
Xfree(pdp); free(pdp);
return NULL; return NULL;
} }
@@ -636,13 +636,13 @@ driswCreateScreen(int screen, struct glx_display *priv)
struct glx_config *configs = NULL, *visuals = NULL; struct glx_config *configs = NULL, *visuals = NULL;
int i; int i;
psc = Xcalloc(1, sizeof *psc); psc = calloc(1, sizeof *psc);
if (psc == NULL) if (psc == NULL)
return NULL; return NULL;
memset(psc, 0, sizeof *psc); memset(psc, 0, sizeof *psc);
if (!glx_screen_init(&psc->base, screen, priv)) { if (!glx_screen_init(&psc->base, screen, priv)) {
Xfree(psc); free(psc);
return NULL; return NULL;
} }
@@ -713,7 +713,7 @@ driswCreateScreen(int screen, struct glx_display *priv)
if (psc->driver) if (psc->driver)
dlclose(psc->driver); dlclose(psc->driver);
glx_screen_cleanup(&psc->base); glx_screen_cleanup(&psc->base);
Xfree(psc); free(psc);
CriticalErrorMessageF("failed to load driver: %s\n", SWRAST_DRIVER_NAME); CriticalErrorMessageF("failed to load driver: %s\n", SWRAST_DRIVER_NAME);
@@ -725,7 +725,7 @@ driswCreateScreen(int screen, struct glx_display *priv)
static void static void
driswDestroyDisplay(__GLXDRIdisplay * dpy) driswDestroyDisplay(__GLXDRIdisplay * dpy)
{ {
Xfree(dpy); free(dpy);
} }
/* /*
@@ -738,7 +738,7 @@ driswCreateDisplay(Display * dpy)
{ {
struct drisw_display *pdpyp; struct drisw_display *pdpyp;
pdpyp = Xmalloc(sizeof *pdpyp); pdpyp = malloc(sizeof *pdpyp);
if (pdpyp == NULL) if (pdpyp == NULL)
return NULL; return NULL;

View File

@@ -326,7 +326,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
length = reply.length; length = reply.length;
if (length) { if (length) {
num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
data = (CARD32 *) Xmalloc(length * sizeof(CARD32)); data = (CARD32 *) malloc(length * sizeof(CARD32));
if (data == NULL) { if (data == NULL) {
/* Throw data on the floor */ /* Throw data on the floor */
_XEatData(dpy, length); _XEatData(dpy, length);
@@ -357,7 +357,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
} }
#endif #endif
Xfree(data); free(data);
} }
} }
@@ -412,7 +412,7 @@ CreateDrawable(Display *dpy, struct glx_config *config,
if (!opcode) if (!opcode)
return None; return None;
glxDraw = Xmalloc(sizeof(*glxDraw)); glxDraw = malloc(sizeof(*glxDraw));
if (!glxDraw) if (!glxDraw)
return None; return None;
@@ -907,7 +907,7 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
return None; return None;
} }
XFree(visinfo); free(visinfo);
return win; return win;
#else #else

View File

@@ -56,7 +56,7 @@ __glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
/* The spec doesn't mention this, but the Xorg server replies with /* The spec doesn't mention this, but the Xorg server replies with
* a string already terminated with '\0'. */ * a string already terminated with '\0'. */
uint32_t len = xcb_glx_query_server_string_string_length(reply); uint32_t len = xcb_glx_query_server_string_string_length(reply);
char *buf = Xmalloc(len); char *buf = malloc(len);
memcpy(buf, xcb_glx_query_server_string_string(reply), len); memcpy(buf, xcb_glx_query_server_string_string(reply), len);
free(reply); free(reply);
@@ -80,7 +80,7 @@ __glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name)
/* The spec doesn't mention this, but the Xorg server replies with /* The spec doesn't mention this, but the Xorg server replies with
* a string already terminated with '\0'. */ * a string already terminated with '\0'. */
uint32_t len = xcb_glx_get_string_string_length(reply); uint32_t len = xcb_glx_get_string_string_length(reply);
char *buf = Xmalloc(len); char *buf = malloc(len);
memcpy(buf, xcb_glx_get_string_string(reply), len); memcpy(buf, xcb_glx_get_string_string(reply), len);
free(reply); free(reply);
@@ -146,7 +146,7 @@ __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
length = reply.length * 4; length = reply.length * 4;
numbytes = reply.size; numbytes = reply.size;
buf = (char *) Xmalloc(numbytes); buf = (char *) malloc(numbytes);
if (buf != NULL) { if (buf != NULL) {
_XRead(dpy, buf, numbytes); _XRead(dpy, buf, numbytes);
length -= numbytes; length -= numbytes;

View File

@@ -669,7 +669,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
return None; return None;
} }
glxDraw = Xmalloc(sizeof(*glxDraw)); glxDraw = malloc(sizeof(*glxDraw));
if (!glxDraw) if (!glxDraw)
return None; return None;
@@ -1267,7 +1267,7 @@ glXChooseVisual(Display * dpy, int screen, int *attribList)
&visualTemplate, &i); &visualTemplate, &i);
if (newList) { if (newList) {
Xfree(visualList); free(visualList);
visualList = newList; visualList = newList;
best_config = config; best_config = config;
} }
@@ -1392,7 +1392,7 @@ __glXClientInfo(Display * dpy, int opcode)
SyncHandle(); SyncHandle();
#endif /* USE_XCB */ #endif /* USE_XCB */
Xfree(ext_str); free(ext_str);
} }
@@ -1628,7 +1628,7 @@ glXChooseFBConfig(Display * dpy, int screen,
if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) { if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) {
list_size = choose_visual(config_list, list_size, attribList, GL_TRUE); list_size = choose_visual(config_list, list_size, attribList, GL_TRUE);
if (list_size == 0) { if (list_size == 0) {
XFree(config_list); free(config_list);
config_list = NULL; config_list = NULL;
} }
} }
@@ -1682,7 +1682,7 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements)
} }
} }
config_list = Xmalloc(num_configs * sizeof *config_list); config_list = malloc(num_configs * sizeof *config_list);
if (config_list != NULL) { if (config_list != NULL) {
*nelements = num_configs; *nelements = num_configs;
i = 0; i = 0;
@@ -2454,7 +2454,7 @@ _X_HIDDEN char *
__glXstrdup(const char *str) __glXstrdup(const char *str)
{ {
char *copy; char *copy;
copy = (char *) Xmalloc(strlen(str) + 1); copy = (char *) malloc(strlen(str) + 1);
if (!copy) if (!copy)
return NULL; return NULL;
strcpy(copy, str); strcpy(copy, str);

View File

@@ -208,13 +208,13 @@ FreeScreenConfigs(struct glx_display * priv)
if (psc->driScreen) { if (psc->driScreen) {
psc->driScreen->destroyScreen(psc); psc->driScreen->destroyScreen(psc);
} else { } else {
Xfree(psc); free(psc);
} }
#else #else
Xfree(psc); free(psc);
#endif #endif
} }
XFree((char *) priv->screens); free((char *) priv->screens);
priv->screens = NULL; priv->screens = NULL;
} }
@@ -231,9 +231,9 @@ glx_display_free(struct glx_display *priv)
FreeScreenConfigs(priv); FreeScreenConfigs(priv);
if (priv->serverGLXvendor) if (priv->serverGLXvendor)
Xfree((char *) priv->serverGLXvendor); free((char *) priv->serverGLXvendor);
if (priv->serverGLXversion) if (priv->serverGLXversion)
Xfree((char *) priv->serverGLXversion); free((char *) priv->serverGLXversion);
__glxHashDestroy(priv->glXDrawHash); __glxHashDestroy(priv->glXDrawHash);
@@ -254,7 +254,7 @@ glx_display_free(struct glx_display *priv)
priv->dri2Display = NULL; priv->dri2Display = NULL;
#endif #endif
Xfree((char *) priv); free((char *) priv);
} }
static int static int
@@ -614,7 +614,7 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
if (prop_size <= sizeof(buf)) if (prop_size <= sizeof(buf))
props = buf; props = buf;
else else
props = Xmalloc(prop_size); props = malloc(prop_size);
/* Read each config structure and convert it into our format */ /* Read each config structure and convert it into our format */
m = modes; m = modes;
@@ -638,7 +638,7 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
} }
if (props != buf) if (props != buf)
Xfree(props); free(props);
return modes; return modes;
} }
@@ -741,14 +741,14 @@ glx_screen_cleanup(struct glx_screen *psc)
if (psc->configs) { if (psc->configs) {
glx_config_destroy_list(psc->configs); glx_config_destroy_list(psc->configs);
if (psc->effectiveGLXexts) if (psc->effectiveGLXexts)
Xfree(psc->effectiveGLXexts); free(psc->effectiveGLXexts);
psc->configs = NULL; /* NOTE: just for paranoia */ psc->configs = NULL; /* NOTE: just for paranoia */
} }
if (psc->visuals) { if (psc->visuals) {
glx_config_destroy_list(psc->visuals); glx_config_destroy_list(psc->visuals);
psc->visuals = NULL; /* NOTE: just for paranoia */ psc->visuals = NULL; /* NOTE: just for paranoia */
} }
Xfree((char *) psc->serverGLXexts); free((char *) psc->serverGLXexts);
} }
/* /*
@@ -765,7 +765,7 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
** First allocate memory for the array of per screen configs. ** First allocate memory for the array of per screen configs.
*/ */
screens = ScreenCount(dpy); screens = ScreenCount(dpy);
priv->screens = Xmalloc(screens * sizeof *priv->screens); priv->screens = malloc(screens * sizeof *priv->screens);
if (!priv->screens) if (!priv->screens)
return GL_FALSE; return GL_FALSE;
@@ -823,13 +823,13 @@ __glXInitialize(Display * dpy)
/* Drop the lock while we create the display private. */ /* Drop the lock while we create the display private. */
_XUnlockMutex(_Xglobal_lock); _XUnlockMutex(_Xglobal_lock);
dpyPriv = Xcalloc(1, sizeof *dpyPriv); dpyPriv = calloc(1, sizeof *dpyPriv);
if (!dpyPriv) if (!dpyPriv)
return NULL; return NULL;
dpyPriv->codes = XInitExtension(dpy, __glXExtensionName); dpyPriv->codes = XInitExtension(dpy, __glXExtensionName);
if (!dpyPriv->codes) { if (!dpyPriv->codes) {
Xfree(dpyPriv); free(dpyPriv);
_XUnlockMutex(_Xglobal_lock); _XUnlockMutex(_Xglobal_lock);
return NULL; return NULL;
} }
@@ -845,7 +845,7 @@ __glXInitialize(Display * dpy)
if (!QueryVersion(dpy, dpyPriv->majorOpcode, if (!QueryVersion(dpy, dpyPriv->majorOpcode,
&dpyPriv->majorVersion, &dpyPriv->minorVersion) &dpyPriv->majorVersion, &dpyPriv->minorVersion)
|| (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion < 1)) { || (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion < 1)) {
Xfree(dpyPriv); free(dpyPriv);
_XUnlockMutex(_Xglobal_lock); _XUnlockMutex(_Xglobal_lock);
return NULL; return NULL;
} }
@@ -881,12 +881,12 @@ __glXInitialize(Display * dpy)
#ifdef GLX_USE_APPLEGL #ifdef GLX_USE_APPLEGL
if (!applegl_create_display(dpyPriv)) { if (!applegl_create_display(dpyPriv)) {
Xfree(dpyPriv); free(dpyPriv);
return NULL; return NULL;
} }
#endif #endif
if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
Xfree(dpyPriv); free(dpyPriv);
return NULL; return NULL;
} }

View File

@@ -509,7 +509,7 @@ __glXGetStringFromTable(const struct extension_info *ext,
} }
} }
ext_str = Xmalloc(ext_str_len + 1); ext_str = malloc(ext_str_len + 1);
if (ext_str != NULL) { if (ext_str != NULL) {
point = ext_str; point = ext_str;

View File

@@ -46,17 +46,17 @@ indirect_destroy_context(struct glx_context *gc)
__glXFreeVertexArrayState(gc); __glXFreeVertexArrayState(gc);
if (gc->vendor) if (gc->vendor)
XFree((char *) gc->vendor); free((char *) gc->vendor);
if (gc->renderer) if (gc->renderer)
XFree((char *) gc->renderer); free((char *) gc->renderer);
if (gc->version) if (gc->version)
XFree((char *) gc->version); free((char *) gc->version);
if (gc->extensions) if (gc->extensions)
XFree((char *) gc->extensions); free((char *) gc->extensions);
__glFreeAttributeState(gc); __glFreeAttributeState(gc);
XFree((char *) gc->buf); free((char *) gc->buf);
Xfree((char *) gc->client_state_private); free((char *) gc->client_state_private);
XFree((char *) gc); free((char *) gc);
} }
static Bool static Bool
@@ -356,7 +356,7 @@ indirect_create_context(struct glx_screen *psc,
} }
/* Allocate our context record */ /* Allocate our context record */
gc = Xmalloc(sizeof *gc); gc = malloc(sizeof *gc);
if (!gc) { if (!gc) {
/* Out of memory */ /* Out of memory */
return NULL; return NULL;
@@ -366,10 +366,10 @@ indirect_create_context(struct glx_screen *psc,
glx_context_init(gc, psc, mode); glx_context_init(gc, psc, mode);
gc->isDirect = GL_FALSE; gc->isDirect = GL_FALSE;
gc->vtable = &indirect_context_vtable; gc->vtable = &indirect_context_vtable;
state = Xmalloc(sizeof(struct __GLXattributeRec)); state = malloc(sizeof(struct __GLXattributeRec));
if (state == NULL) { if (state == NULL) {
/* Out of memory */ /* Out of memory */
Xfree(gc); free(gc);
return NULL; return NULL;
} }
gc->client_state_private = state; gc->client_state_private = state;
@@ -384,10 +384,10 @@ indirect_create_context(struct glx_screen *psc,
*/ */
bufSize = (XMaxRequestSize(psc->dpy) * 4) - sz_xGLXRenderReq; bufSize = (XMaxRequestSize(psc->dpy) * 4) - sz_xGLXRenderReq;
gc->buf = (GLubyte *) Xmalloc(bufSize); gc->buf = (GLubyte *) malloc(bufSize);
if (!gc->buf) { if (!gc->buf) {
Xfree(gc->client_state_private); free(gc->client_state_private);
Xfree(gc); free(gc);
return NULL; return NULL;
} }
gc->bufSize = bufSize; gc->bufSize = bufSize;
@@ -468,7 +468,7 @@ indirect_create_screen(int screen, struct glx_display * priv)
{ {
struct glx_screen *psc; struct glx_screen *psc;
psc = Xmalloc(sizeof *psc); psc = malloc(sizeof *psc);
if (psc == NULL) if (psc == NULL)
return NULL; return NULL;

View File

@@ -89,14 +89,14 @@ __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
if (stride != k) { if (stride != k) {
GLubyte *buf; GLubyte *buf;
buf = (GLubyte *) Xmalloc(compsize); buf = (GLubyte *) malloc(compsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
} }
__glFillMap1d(k, order, stride, pnts, buf); __glFillMap1d(k, order, stride, pnts, buf);
__glXSendLargeCommand(gc, pc, 32, buf, compsize); __glXSendLargeCommand(gc, pc, 32, buf, compsize);
Xfree((char *) buf); free((char *) buf);
} }
else { else {
/* Data is already packed. Just send it out */ /* Data is already packed. Just send it out */
@@ -152,14 +152,14 @@ __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
if (stride != k) { if (stride != k) {
GLubyte *buf; GLubyte *buf;
buf = (GLubyte *) Xmalloc(compsize); buf = (GLubyte *) malloc(compsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
} }
__glFillMap1f(k, order, stride, pnts, buf); __glFillMap1f(k, order, stride, pnts, buf);
__glXSendLargeCommand(gc, pc, 24, buf, compsize); __glXSendLargeCommand(gc, pc, 24, buf, compsize);
Xfree((char *) buf); free((char *) buf);
} }
else { else {
/* Data is already packed. Just send it out */ /* Data is already packed. Just send it out */
@@ -227,7 +227,7 @@ __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr,
if ((vstr != k) || (ustr != k * vord)) { if ((vstr != k) || (ustr != k * vord)) {
GLdouble *buf; GLdouble *buf;
buf = (GLdouble *) Xmalloc(compsize); buf = (GLdouble *) malloc(compsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
@@ -237,7 +237,7 @@ __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr,
*/ */
__glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf); __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
__glXSendLargeCommand(gc, pc, 52, buf, compsize); __glXSendLargeCommand(gc, pc, 52, buf, compsize);
Xfree((char *) buf); free((char *) buf);
} }
else { else {
/* Data is already packed. Just send it out */ /* Data is already packed. Just send it out */
@@ -303,7 +303,7 @@ __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr,
if ((vstr != k) || (ustr != k * vord)) { if ((vstr != k) || (ustr != k * vord)) {
GLfloat *buf; GLfloat *buf;
buf = (GLfloat *) Xmalloc(compsize); buf = (GLfloat *) malloc(compsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
@@ -313,7 +313,7 @@ __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr,
*/ */
__glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf); __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
__glXSendLargeCommand(gc, pc, 36, buf, compsize); __glXSendLargeCommand(gc, pc, 36, buf, compsize);
Xfree((char *) buf); free((char *) buf);
} }
else { else {
/* Data is already packed. Just send it out */ /* Data is already packed. Just send it out */

View File

@@ -84,7 +84,7 @@ __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
GLubyte * pc, GLubyte * modes) GLubyte * pc, GLubyte * modes)
{ {
/* Allocate a temporary holding buffer */ /* Allocate a temporary holding buffer */
GLubyte *buf = (GLubyte *) Xmalloc(compsize); GLubyte *buf = (GLubyte *) malloc(compsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
@@ -108,7 +108,7 @@ __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
__glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize); __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
/* Free buffer */ /* Free buffer */
Xfree((char *) buf); free((char *) buf);
} }
/************************************************************************/ /************************************************************************/
@@ -178,7 +178,7 @@ __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
pc += hdrlen; pc += hdrlen;
/* Allocate a temporary holding buffer */ /* Allocate a temporary holding buffer */
buf = (GLubyte *) Xmalloc(bufsize); buf = (GLubyte *) malloc(bufsize);
if (!buf) { if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY); __glXSetError(gc, GL_OUT_OF_MEMORY);
return; return;
@@ -193,6 +193,6 @@ __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
__glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf, __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf,
bufsize); bufsize);
/* Free buffer */ /* Free buffer */
Xfree((char *) buf); free((char *) buf);
} }
} }

View File

@@ -721,7 +721,7 @@ __indirect_glGetString(GLenum name)
*/ */
const size_t size = 7 + strlen((char *) s) + 4; const size_t size = 7 + strlen((char *) s) + 4;
gc->version = Xmalloc(size); gc->version = malloc(size);
if (gc->version == NULL) { if (gc->version == NULL) {
/* If we couldn't allocate memory for the new string, /* If we couldn't allocate memory for the new string,
* make a best-effort and just copy the client-side version * make a best-effort and just copy the client-side version
@@ -737,7 +737,7 @@ __indirect_glGetString(GLenum name)
else { else {
snprintf((char *) gc->version, size, "%u.%u (%s)", snprintf((char *) gc->version, size, "%u.%u (%s)",
client_major, client_minor, s); client_major, client_minor, s);
Xfree(s); free(s);
s = gc->version; s = gc->version;
} }
} }
@@ -782,7 +782,7 @@ __indirect_glGetString(GLenum name)
#endif #endif
__glXCalculateUsableGLExtensions(gc, (char *) s, major, minor); __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor);
XFree(s); free(s);
s = gc->extensions; s = gc->extensions;
break; break;
} }

View File

@@ -68,7 +68,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
heightsize = __glImageSize(height, 1, 1, format, type, 0); heightsize = __glImageSize(height, 1, 1, format, type, 0);
/* Allocate a holding buffer to transform the data from */ /* Allocate a holding buffer to transform the data from */
rowBuf = (GLubyte *) Xmalloc(widthsize); rowBuf = (GLubyte *) malloc(widthsize);
if (!rowBuf) { if (!rowBuf) {
/* Throw data away */ /* Throw data away */
_XEatData(dpy, compsize); _XEatData(dpy, compsize);
@@ -80,9 +80,9 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
else { else {
__GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize); __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize);
__glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
Xfree((char *) rowBuf); free((char *) rowBuf);
} }
colBuf = (GLubyte *) Xmalloc(heightsize); colBuf = (GLubyte *) malloc(heightsize);
if (!colBuf) { if (!colBuf) {
/* Throw data away */ /* Throw data away */
_XEatData(dpy, compsize - __GLX_PAD(widthsize)); _XEatData(dpy, compsize - __GLX_PAD(widthsize));
@@ -94,7 +94,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
else { else {
__GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize); __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize);
__glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column); __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
Xfree((char *) colBuf); free((char *) colBuf);
} }
} }
else { else {
@@ -155,8 +155,7 @@ void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format,
const GLint heightsize = const GLint heightsize =
__glImageSize(height, 1, 1, format, type, 0); __glImageSize(height, 1, 1, format, type, 0);
GLubyte *const buf = GLubyte *const buf =
(GLubyte *) Xmalloc((widthsize > heightsize) ? widthsize : (GLubyte *) malloc((widthsize > heightsize) ? widthsize : heightsize);
heightsize);
if (buf == NULL) { if (buf == NULL) {
/* Throw data away */ /* Throw data away */
@@ -186,7 +185,7 @@ void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format,
__glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column);
Xfree((char *) buf); free((char *) buf);
} }
} }
} }

View File

@@ -245,7 +245,7 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis
max_bm_width = (max_width + 7) / 8; max_bm_width = (max_width + 7) / 8;
max_bm_height = max_height; max_bm_height = max_height;
bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); bm = (GLubyte *) malloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
if (!bm) { if (!bm) {
XFreeFontInfo(NULL, fs, 1); XFreeFontInfo(NULL, fs, 1);
__glXSetError(CC, GL_OUT_OF_MEMORY); __glXSetError(CC, GL_OUT_OF_MEMORY);
@@ -359,7 +359,7 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis
glEndList(); glEndList();
} }
Xfree(bm); free(bm);
XFreeFontInfo(NULL, fs, 1); XFreeFontInfo(NULL, fs, 1);
XFreeGC(dpy, gc); XFreeGC(dpy, gc);

View File

@@ -201,7 +201,7 @@ GetOverlayInfo(Display *dpy, int screen, int *numOverlays)
if (status != Success || actualType != overlayVisualsAtom || if (status != Success || actualType != overlayVisualsAtom ||
actualFormat != 32 || sizeData < 4) { actualFormat != 32 || sizeData < 4) {
/* something went wrong */ /* something went wrong */
XFree((void *) ovInfo); free((void *) ovInfo);
*numOverlays = 0; *numOverlays = 0;
return NULL; return NULL;
} }
@@ -239,18 +239,18 @@ level_of_visual( Display *dpy, XVisualInfo *vinfo )
/* found the visual */ /* found the visual */
if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
int level = ov->layer; int level = ov->layer;
XFree((void *) overlay_info); free((void *) overlay_info);
return level; return level;
} }
else { else {
XFree((void *) overlay_info); free((void *) overlay_info);
return 0; return 0;
} }
} }
} }
/* The visual ID was not found in the overlay list. */ /* The visual ID was not found in the overlay list. */
XFree((void *) overlay_info); free((void *) overlay_info);
return 0; return 0;
} }
@@ -497,19 +497,19 @@ transparent_pixel( XMesaVisual glxvis )
/* found it! */ /* found it! */
if (ov->transparent_type == 0) { if (ov->transparent_type == 0) {
/* type 0 indicates no transparency */ /* type 0 indicates no transparency */
XFree((void *) overlay_info); free((void *) overlay_info);
return -1; return -1;
} }
else { else {
/* ov->value is the transparent pixel */ /* ov->value is the transparent pixel */
XFree((void *) overlay_info); free((void *) overlay_info);
return ov->value; return ov->value;
} }
} }
} }
/* The visual ID was not found in the overlay list. */ /* The visual ID was not found in the overlay list. */
XFree((void *) overlay_info); free((void *) overlay_info);
return -1; return -1;
} }
@@ -554,7 +554,7 @@ get_visual( Display *dpy, int scr, unsigned int depth, int xclass )
return vis; return vis;
} }
else { else {
XFree((void *) vis); free((void *) vis);
return NULL; return NULL;
} }
} }
@@ -780,7 +780,7 @@ choose_x_overlay_visual( Display *dpy, int scr,
if (deepvis==NULL || vislist->depth > deepest) { if (deepvis==NULL || vislist->depth > deepest) {
/* YES! found a satisfactory visual */ /* YES! found a satisfactory visual */
if (deepvis) { if (deepvis) {
XFree( deepvis ); free(deepvis);
} }
deepest = vislist->depth; deepest = vislist->depth;
deepvis = vislist; deepvis = vislist;