Remove useless checks for NULL before freeing

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

// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
type T;
@@
+ free ((T) E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free((T) E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }

@@
expression E;
type T;
@@
+ free ((T) E);
- if (unlikely (E != NULL)) {
-   free ((T) E);
- }

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Matt Turner
2012-09-03 20:24:35 -07:00
parent a9e8054fff
commit 5067506ea6
46 changed files with 88 additions and 184 deletions

View File

@@ -611,8 +611,7 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
close(dri2_dpy->fd); close(dri2_dpy->fd);
if (dri2_dpy->driver) if (dri2_dpy->driver)
dlclose(dri2_dpy->driver); dlclose(dri2_dpy->driver);
if (dri2_dpy->device_name) free(dri2_dpy->device_name);
free(dri2_dpy->device_name);
if (disp->PlatformDisplay == NULL) { if (disp->PlatformDisplay == NULL) {
switch (disp->Platform) { switch (disp->Platform) {

View File

@@ -581,8 +581,7 @@ dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id)
if (authenticate == NULL || !authenticate->authenticated) if (authenticate == NULL || !authenticate->authenticated)
ret = -1; ret = -1;
if (authenticate) free(authenticate);
free(authenticate);
return ret; return ret;
} }

View File

@@ -655,10 +655,8 @@ GLX_eglTerminate(_EGLDriver *drv, _EGLDisplay *disp)
_eglReleaseDisplayResources(drv, disp); _eglReleaseDisplayResources(drv, disp);
_eglCleanupDisplay(disp); _eglCleanupDisplay(disp);
if (GLX_dpy->visuals) free(GLX_dpy->visuals);
free(GLX_dpy->visuals); free(GLX_dpy->fbconfigs);
if (GLX_dpy->fbconfigs)
free(GLX_dpy->fbconfigs);
if (!disp->PlatformDisplay) if (!disp->PlatformDisplay)
XCloseDisplay(GLX_dpy->dpy); XCloseDisplay(GLX_dpy->dpy);

View File

@@ -4997,10 +4997,8 @@ static void fc_pushlevel(struct r600_shader_ctx *ctx, int type)
static void fc_poplevel(struct r600_shader_ctx *ctx) static void fc_poplevel(struct r600_shader_ctx *ctx)
{ {
struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[ctx->bc->fc_sp]; struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[ctx->bc->fc_sp];
if (sp->mid) { free(sp->mid);
free(sp->mid); sp->mid = NULL;
sp->mid = NULL;
}
sp->num_mid = 0; sp->num_mid = 0;
sp->start = NULL; sp->start = NULL;
sp->type = 0; sp->type = 0;

View File

@@ -217,9 +217,7 @@ __glXFreeDisplayPrivate(XExtData * extension)
priv = (__GLXdisplayPrivate *) extension->private_data; priv = (__GLXdisplayPrivate *) extension->private_data;
FreeScreenConfigs(priv); FreeScreenConfigs(priv);
if (priv->serverGLXversion) free((char *) priv->serverGLXversion);
free((char *) priv->serverGLXversion);
free((char *) priv); free((char *) priv);
return 0; return 0;
} }

View File

@@ -95,10 +95,8 @@ 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) free(xscr->dri_driver);
free(xscr->dri_driver); free(xscr->dri_device);
if (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 */
@@ -106,8 +104,7 @@ x11_screen_destroy(struct x11_screen *xscr)
xscr->glx_dpy->xscr = NULL; xscr->glx_dpy->xscr = NULL;
#endif #endif
if (xscr->visuals) free(xscr->visuals);
free(xscr->visuals);
FREE(xscr); FREE(xscr);
} }

View File

@@ -168,10 +168,8 @@ xmesa_init_display( Display *display )
xmdpy->screen->destroy(xmdpy->screen); xmdpy->screen->destroy(xmdpy->screen);
xmdpy->screen = NULL; xmdpy->screen = NULL;
} }
if (xmdpy->smapi) { free(xmdpy->smapi);
free(xmdpy->smapi); xmdpy->smapi = NULL;
xmdpy->smapi = NULL;
}
xmdpy->display = NULL; xmdpy->display = NULL;
} }

View File

@@ -278,10 +278,8 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b)
stfbi = CALLOC_STRUCT(st_framebuffer_iface); stfbi = CALLOC_STRUCT(st_framebuffer_iface);
xstfb = CALLOC_STRUCT(xmesa_st_framebuffer); xstfb = CALLOC_STRUCT(xmesa_st_framebuffer);
if (!stfbi || !xstfb) { if (!stfbi || !xstfb) {
if (stfbi) free(stfbi);
free(stfbi); free(xstfb);
if (xstfb)
free(xstfb);
return NULL; return NULL;
} }

View File

@@ -238,12 +238,9 @@ combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_sh
ureg_destroy(ureg); ureg_destroy(ureg);
if (temp) free(temp);
free(temp); free(constant);
if (constant) free(sampler);
free(constant);
if (sampler)
free(sampler);
return p; return p;
} }

View File

@@ -115,8 +115,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) free(subpictures);
free(subpictures);
return BadMatch; return BadMatch;
} }
if (!subpictures) if (!subpictures)

View File

@@ -157,8 +157,7 @@ fail:
if (xlib_handle) if (xlib_handle)
FREE(xlib_handle); FREE(xlib_handle);
if (visinfo) free(visinfo);
free(visinfo);
if (win) if (win)
XDestroyWindow(graw.display, win); XDestroyWindow(graw.display, win);

View File

@@ -126,8 +126,7 @@ dri2_destroy_context(struct glx_context *context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) free((char *) context->extensions);
free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);
@@ -313,8 +312,7 @@ dri2_create_context_attribs(struct glx_screen *base,
return &pcp->base; return &pcp->base;
error_exit: error_exit:
if (pcp != NULL) free(pcp);
free(pcp);
return NULL; return NULL;
} }

View File

@@ -495,8 +495,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
if (framebuffer.base != MAP_FAILED) if (framebuffer.base != MAP_FAILED)
drmUnmap((drmAddress) framebuffer.base, framebuffer.size); drmUnmap((drmAddress) framebuffer.base, framebuffer.size);
if (framebuffer.dev_priv != NULL) free(framebuffer.dev_priv);
free(framebuffer.dev_priv);
if (fd >= 0) if (fd >= 0)
drmCloseOnce(fd); drmCloseOnce(fd);
@@ -516,8 +515,7 @@ dri_destroy_context(struct glx_context * context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) free((char *) context->extensions);
free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);

View File

@@ -255,8 +255,7 @@ drisw_destroy_context(struct glx_context *context)
driReleaseDrawables(&pcp->base); driReleaseDrawables(&pcp->base);
if (context->extensions) free((char *) context->extensions);
free((char *) context->extensions);
(*psc->core->destroyContext) (pcp->driContext); (*psc->core->destroyContext) (pcp->driContext);

View File

@@ -230,10 +230,8 @@ glx_display_free(struct glx_display *priv)
} }
FreeScreenConfigs(priv); FreeScreenConfigs(priv);
if (priv->serverGLXvendor) free((char *) priv->serverGLXvendor);
free((char *) priv->serverGLXvendor); free((char *) priv->serverGLXversion);
if (priv->serverGLXversion)
free((char *) priv->serverGLXversion);
__glxHashDestroy(priv->glXDrawHash); __glxHashDestroy(priv->glXDrawHash);
@@ -740,8 +738,7 @@ 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) free(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) {

View File

@@ -45,14 +45,10 @@ indirect_destroy_context(struct glx_context *gc)
{ {
__glXFreeVertexArrayState(gc); __glXFreeVertexArrayState(gc);
if (gc->vendor) free((char *) gc->vendor);
free((char *) gc->vendor); free((char *) gc->renderer);
if (gc->renderer) free((char *) gc->version);
free((char *) gc->renderer); free((char *) gc->extensions);
if (gc->version)
free((char *) gc->version);
if (gc->extensions)
free((char *) gc->extensions);
__glFreeAttributeState(gc); __glFreeAttributeState(gc);
free((char *) gc->buf); free((char *) gc->buf);
free((char *) gc->client_state_private); free((char *) gc->client_state_private);

View File

@@ -115,14 +115,10 @@ __glXFreeVertexArrayState(struct glx_context * gc)
struct array_state_vector *arrays = state->array_state; struct array_state_vector *arrays = state->array_state;
if (arrays) { if (arrays) {
if (arrays->stack) { free(arrays->stack);
free(arrays->stack); arrays->stack = NULL;
arrays->stack = NULL; free(arrays->arrays);
} arrays->arrays = NULL;
if (arrays->arrays) {
free(arrays->arrays);
arrays->arrays = NULL;
}
free(arrays); free(arrays);
state->array_state = NULL; state->array_state = NULL;
} }

View File

@@ -989,8 +989,7 @@ void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
XML_ParserFree (p); XML_ParserFree (p);
} }
if (filenames[1]) free(filenames[1]);
free(filenames[1]);
} }
void driDestroyOptionInfo (driOptionCache *info) { void driDestroyOptionInfo (driOptionCache *info) {
@@ -1000,8 +999,7 @@ void driDestroyOptionInfo (driOptionCache *info) {
for (i = 0; i < size; ++i) { for (i = 0; i < size; ++i) {
if (info->info[i].name) { if (info->info[i].name) {
free(info->info[i].name); free(info->info[i].name);
if (info->info[i].ranges) free(info->info[i].ranges);
free(info->info[i].ranges);
} }
} }
free(info->info); free(info->info);
@@ -1009,8 +1007,7 @@ void driDestroyOptionInfo (driOptionCache *info) {
} }
void driDestroyOptionCache (driOptionCache *cache) { void driDestroyOptionCache (driOptionCache *cache) {
if (cache->values) free(cache->values);
free(cache->values);
} }
GLboolean driCheckOption (const driOptionCache *cache, const char *name, GLboolean driCheckOption (const driOptionCache *cache, const char *name,

View File

@@ -717,10 +717,8 @@ intel_buffer_object_purgeable(struct gl_context * ctx,
return intel_buffer_purgeable(intel_obj->buffer); return intel_buffer_purgeable(intel_obj->buffer);
if (option == GL_RELEASED_APPLE) { if (option == GL_RELEASED_APPLE) {
if (intel_obj->sys_buffer != NULL) { free(intel_obj->sys_buffer);
free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL;
intel_obj->sys_buffer = NULL;
}
return GL_RELEASED_APPLE; return GL_RELEASED_APPLE;
} else { } else {

View File

@@ -150,10 +150,8 @@ intel_free_texture_image_buffer(struct gl_context * ctx,
intelImage->base.Buffer = NULL; intelImage->base.Buffer = NULL;
} }
if (intelImage->base.ImageOffsets) { free(intelImage->base.ImageOffsets);
free(intelImage->base.ImageOffsets); intelImage->base.ImageOffsets = NULL;
intelImage->base.ImageOffsets = NULL;
}
} }
/** /**

View File

@@ -203,8 +203,7 @@ static void radeon_destroy_atom_list(radeonContextPtr radeon)
foreach(atom, &radeon->hw.atomlist) { foreach(atom, &radeon->hw.atomlist) {
free(atom->cmd); free(atom->cmd);
if (atom->lastcmd) free(atom->lastcmd);
free(atom->lastcmd);
} }
} }

View File

@@ -148,10 +148,8 @@ void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_imag
image->base.Buffer = NULL; image->base.Buffer = NULL;
} }
if (image->base.ImageOffsets) { free(image->base.ImageOffsets);
free(image->base.ImageOffsets); image->base.ImageOffsets = NULL;
image->base.ImageOffsets = NULL;
}
} }
/* Set Data pointer and additional data for mapped texture image */ /* Set Data pointer and additional data for mapped texture image */

View File

@@ -779,9 +779,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) { free(deepvis);
free(deepvis);
}
deepest = vislist->depth; deepest = vislist->depth;
deepvis = vislist; deepvis = vislist;
/* DEBUG tt = ov->transparent_type;*/ /* DEBUG tt = ov->transparent_type;*/

View File

@@ -83,10 +83,8 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_sha
{ {
GLuint i; GLuint i;
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
if (s->Instructions[i]) free(s->Instructions[i]);
free(s->Instructions[i]); free(s->SetupInst[i]);
if (s->SetupInst[i])
free(s->SetupInst[i]);
} }
free(s); free(s);
} }
@@ -342,10 +340,8 @@ _mesa_BeginFragmentShaderATI(void)
(or, could use the same mem but would need to reinitialize) */ (or, could use the same mem but would need to reinitialize) */
/* no idea if it's allowed to redefine a shader */ /* no idea if it's allowed to redefine a shader */
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
if (ctx->ATIFragmentShader.Current->Instructions[i]) free(ctx->ATIFragmentShader.Current->Instructions[i]);
free(ctx->ATIFragmentShader.Current->Instructions[i]); free(ctx->ATIFragmentShader.Current->SetupInst[i]);
if (ctx->ATIFragmentShader.Current->SetupInst[i])
free(ctx->ATIFragmentShader.Current->SetupInst[i]);
} }
/* malloc the instructions here - not sure if the best place but its /* malloc the instructions here - not sure if the best place but its

View File

@@ -264,8 +264,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
{ {
(void) ctx; (void) ctx;
if (bufObj->Data) free(bufObj->Data);
free(bufObj->Data);
/* assign strange values here to help w/ debugging */ /* assign strange values here to help w/ debugging */
bufObj->RefCount = -1000; bufObj->RefCount = -1000;

View File

@@ -1158,11 +1158,9 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_errors_data(ctx); _mesa_free_errors_data(ctx);
if (ctx->Extensions.String) free((void *)ctx->Extensions.String);
free((void *) ctx->Extensions.String);
if (ctx->VersionString) free(ctx->VersionString);
free(ctx->VersionString);
/* unbind the context if it's currently bound */ /* unbind the context if it's currently bound */
if (ctx == _mesa_get_current_context()) { if (ctx == _mesa_get_current_context()) {

View File

@@ -218,8 +218,7 @@ _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
void *newBuffer = malloc(newSize); void *newBuffer = malloc(newSize);
if (newBuffer && oldBuffer && copySize > 0) if (newBuffer && oldBuffer && copySize > 0)
memcpy(newBuffer, oldBuffer, copySize); memcpy(newBuffer, oldBuffer, copySize);
if (oldBuffer) free(oldBuffer);
free(oldBuffer);
return newBuffer; return newBuffer;
} }

View File

@@ -703,9 +703,7 @@ shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source)
return; return;
/* free old shader source string and install new one */ /* free old shader source string and install new one */
if (sh->Source) { free((void *)sh->Source);
free((void *) sh->Source);
}
sh->Source = source; sh->Source = source;
sh->CompileStatus = GL_FALSE; sh->CompileStatus = GL_FALSE;
#ifdef DEBUG #ifdef DEBUG

View File

@@ -124,8 +124,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
static void static void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
{ {
if (sh->Source) free((void *)sh->Source);
free((void *) sh->Source);
_mesa_reference_program(ctx, &sh->Program, NULL); _mesa_reference_program(ctx, &sh->Program, NULL);
ralloc_free(sh); ralloc_free(sh);
} }
@@ -333,10 +332,8 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
} }
shProg->NumShaders = 0; shProg->NumShaders = 0;
if (shProg->Shaders) { free(shProg->Shaders);
free(shProg->Shaders); shProg->Shaders = NULL;
shProg->Shaders = NULL;
}
/* Transform feedback varying vars */ /* Transform feedback varying vars */
for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {

View File

@@ -214,8 +214,7 @@ _mesa_cpal_compressed_teximage2d(GLenum target, GLint level,
_mesa_TexImage2D(target, lvl, info->format, w, h, 0, _mesa_TexImage2D(target, lvl, info->format, w, h, 0,
info->format, info->type, image); info->format, info->type, image);
if (image) free(image);
free(image);
/* advance index pointer to point to next src mipmap */ /* advance index pointer to point to next src mipmap */
if (info->palette_size == 16) if (info->palette_size == 16)

View File

@@ -1361,9 +1361,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
} }
cleanUp: cleanUp:
if (newSource != NULL) { free(newSource);
free(newSource);
}
} }

View File

@@ -84,8 +84,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
return; return;
} }
if (program->Base.String != NULL) free(program->Base.String);
free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the /* Copy the relevant contents of the arb_program struct into the
* fragment_program struct. * fragment_program struct.
@@ -122,8 +121,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
program->UsesKill = state.fragment.UsesKill; program->UsesKill = state.fragment.UsesKill;
program->UsesDFdy = state.fragment.UsesDFdy; program->UsesDFdy = state.fragment.UsesDFdy;
if (program->Base.Instructions) free(program->Base.Instructions);
free(program->Base.Instructions);
program->Base.Instructions = prog.Instructions; program->Base.Instructions = prog.Instructions;
if (program->Base.Parameters) if (program->Base.Parameters)
@@ -179,8 +177,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
return; return;
} }
if (program->Base.String != NULL) free(program->Base.String);
free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the /* Copy the relevant contents of the arb_program struct into the
* vertex_program struct. * vertex_program struct.
@@ -202,8 +199,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
program->IsPositionInvariant = (state.option.PositionInvariant) program->IsPositionInvariant = (state.option.PositionInvariant)
? GL_TRUE : GL_FALSE; ? GL_TRUE : GL_FALSE;
if (program->Base.Instructions) free(program->Base.Instructions);
free(program->Base.Instructions);
program->Base.Instructions = prog.Instructions; program->Base.Instructions = prog.Instructions;
if (program->Base.Parameters) if (program->Base.Parameters)

View File

@@ -1549,14 +1549,10 @@ _mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget,
/* install the program */ /* install the program */
program->Base.Target = target; program->Base.Target = target;
if (program->Base.String) { free(program->Base.String);
free(program->Base.String);
}
program->Base.String = programString; program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
if (program->Base.Instructions) { free(program->Base.Instructions);
free(program->Base.Instructions);
}
program->Base.Instructions = newInst; program->Base.Instructions = newInst;
program->Base.NumInstructions = parseState.numInst; program->Base.NumInstructions = parseState.numInst;
program->Base.InputsRead = parseState.inputsRead; program->Base.InputsRead = parseState.inputsRead;

View File

@@ -1382,14 +1382,10 @@ _mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget,
/* install the program */ /* install the program */
program->Base.Target = target; program->Base.Target = target;
if (program->Base.String) { free(program->Base.String);
free(program->Base.String);
}
program->Base.String = programString; program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
if (program->Base.Instructions) { free(program->Base.Instructions);
free(program->Base.Instructions);
}
program->Base.Instructions = newInst; program->Base.Instructions = newInst;
program->Base.InputsRead = parseState.inputsRead; program->Base.InputsRead = parseState.inputsRead;
if (parseState.isPositionInvariant) if (parseState.isPositionInvariant)

View File

@@ -127,10 +127,8 @@ _mesa_free_instructions(struct prog_instruction *inst, GLuint count)
{ {
GLuint i; GLuint i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (inst[i].Data) free(inst[i].Data);
free(inst[i].Data); free((char *)inst[i].Comment);
if (inst[i].Comment)
free((char *) inst[i].Comment);
} }
free(inst); free(inst);
} }

View File

@@ -80,8 +80,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
{ {
GLuint i; GLuint i;
for (i = 0; i < paramList->NumParameters; i++) { for (i = 0; i < paramList->NumParameters; i++) {
if (paramList->Parameters[i].Name) free((void *)paramList->Parameters[i].Name);
free((void *) paramList->Parameters[i].Name);
} }
free(paramList->Parameters); free(paramList->Parameters);
if (paramList->ParameterValues) if (paramList->ParameterValues)

View File

@@ -382,8 +382,7 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
if (prog == &_mesa_DummyProgram) if (prog == &_mesa_DummyProgram)
return; return;
if (prog->String) free(prog->String);
free(prog->String);
if (prog->Instructions) { if (prog->Instructions) {
_mesa_free_instructions(prog->Instructions, prog->NumInstructions); _mesa_free_instructions(prog->Instructions, prog->NumInstructions);

View File

@@ -835,8 +835,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage"); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
} }
if (tempSrc) free(tempSrc);
free(tempSrc);
} }
st_texture_image_unmap(st, stImage); st_texture_image_unmap(st, stImage);

View File

@@ -829,8 +829,7 @@ _swrast_DestroyContext( struct gl_context *ctx )
} }
free( swrast->SpanArrays ); free( swrast->SpanArrays );
if (swrast->ZoomedArrays) free( swrast->ZoomedArrays );
free( swrast->ZoomedArrays );
free( swrast->TexelBuffer ); free( swrast->TexelBuffer );
free(swrast->stencil_temp.buf1); free(swrast->stencil_temp.buf1);

View File

@@ -493,9 +493,7 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
span.array->ChanType = CHAN_TYPE; span.array->ChanType = CHAN_TYPE;
} }
if (convImage) { free(convImage);
free(convImage);
}
swrast_render_finish(ctx); swrast_render_finish(ctx);
} }

View File

@@ -119,10 +119,8 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
bpp = _mesa_get_format_bytes(rb->Format); bpp = _mesa_get_format_bytes(rb->Format);
/* free old buffer storage */ /* free old buffer storage */
if (srb->Buffer) { free(srb->Buffer);
free(srb->Buffer); srb->Buffer = NULL;
srb->Buffer = NULL;
}
srb->RowStride = width * bpp; srb->RowStride = width * bpp;
@@ -170,10 +168,8 @@ soft_renderbuffer_delete(struct gl_renderbuffer *rb)
{ {
struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
if (srb->Buffer) { free(srb->Buffer);
free(srb->Buffer); srb->Buffer = NULL;
srb->Buffer = NULL;
}
_mesa_delete_renderbuffer(rb); _mesa_delete_renderbuffer(rb);
} }

View File

@@ -144,10 +144,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
swImage->Buffer = NULL; swImage->Buffer = NULL;
} }
if (swImage->ImageOffsets) { free(swImage->ImageOffsets);
free(swImage->ImageOffsets); swImage->ImageOffsets = NULL;
swImage->ImageOffsets = NULL;
}
} }

View File

@@ -589,8 +589,8 @@ static void free_texgen_data( struct tnl_pipeline_stage *stage )
_mesa_vector4f_free( &store->texcoord[i] ); _mesa_vector4f_free( &store->texcoord[i] );
if (store->tmp_f) free( store->tmp_f ); free( store->tmp_f );
if (store->tmp_m) free( store->tmp_m ); free( store->tmp_m );
free( store ); free( store );
stage->privatePtr = NULL; stage->privatePtr = NULL;
} }

View File

@@ -226,8 +226,6 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
} }
} }
if (sub_prims) { free(sub_prims);
free(sub_prims);
}
} }

View File

@@ -242,11 +242,9 @@ void vbo_rebase_prims( struct gl_context *ctx,
ctx->Array._DrawArrays = saved_arrays; ctx->Array._DrawArrays = saved_arrays;
ctx->NewDriverState |= ctx->DriverFlags.NewArray; ctx->NewDriverState |= ctx->DriverFlags.NewArray;
if (tmp_indices) free(tmp_indices);
free(tmp_indices);
if (tmp_prims) free(tmp_prims);
free(tmp_prims);
} }

View File

@@ -1577,10 +1577,8 @@ vbo_destroy_vertex_list(struct gl_context *ctx, void *data)
if (--node->prim_store->refcount == 0) if (--node->prim_store->refcount == 0)
free(node->prim_store); free(node->prim_store);
if (node->current_data) { free(node->current_data);
free(node->current_data); node->current_data = NULL;
node->current_data = NULL;
}
} }