mesa: Don't check for image->Data when freeing an image's contents.
authorEric Anholt <eric@anholt.net>
Wed, 27 Jul 2011 21:40:08 +0000 (14:40 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 29 Aug 2011 17:10:03 +0000 (10:10 -0700)
All driver implementations of FreeTextureImageBuffer already check
that Data != NULL and free it.  However, this means that we will also
free driver storage if the driver storage wasn't in the form of a Data
pointer.

This was produced by the following semantic patch:

@@
expression C;
expression T;
@@
- if (T->Data) {
- C->Driver.FreeTextureImageBuffer(C, T);
+ C->Driver.FreeTextureImageBuffer(C, T);
- }

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/mipmap.c
src/mesa/main/teximage.c
src/mesa/state_tracker/st_gen_mipmap.c

index 611f3755010d90d4bc43663c971a78c4069b3886..cf9d522f2f17354a7489cb7c73b57596ca5f4fb2 100644 (file)
@@ -1948,8 +1948,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
       }
 
       /* Free old image data */
-      if (dstImage->Data)
-         ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
+      ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
 
       /* initialize new image */
       _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
index 8fdebad194063be408f91b1937430536746dadb6..886e52114f24d2f1eccea1766bb514f2881ac3c9 100644 (file)
@@ -2456,9 +2456,7 @@ teximage(struct gl_context *ctx, GLuint dims,
          else {
             gl_format texFormat;
 
-            if (texImage->Data) {
-               ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
-            }
+            ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
 
             ASSERT(texImage->Data == NULL);
             texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
@@ -2597,8 +2595,7 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
    if (!texImage) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D");
    } else {
-      if (texImage->Data)
-        ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
+      ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
 
       ASSERT(texImage->Data == NULL);
       ctx->Driver.EGLImageTargetTexture2D(ctx, target,
@@ -3362,9 +3359,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
          else {
             gl_format texFormat;
 
-            if (texImage->Data) {
-               ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
-            }
+            ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
             ASSERT(texImage->Data == NULL);
 
             texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
index c991da36670b56731e26a0d5d321b6ad551ec3c7..e53da5fd4aea7e137d2bdd819e80655748426159 100644 (file)
@@ -444,8 +444,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
       }
 
       /* Free old image data */
-      if (dstImage->Data)
-         ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
+      ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
 
       /* initialize new image */
       _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,