scons: Build glu.
[mesa.git] / src / glu / sgi / libutil / mipmap.c
index af647af73c98cbc1bda3e61835a01a82142050a1..71e76afb8720ebe7652830e70b6910ddf84bd91a 100644 (file)
@@ -36,7 +36,6 @@
 #include <string.h>
 #include <limits.h>            /* UINT_MAX */
 #include <math.h>
-#include "gluint.h"
 
 typedef union {
     unsigned char ub[4];
@@ -3526,6 +3525,8 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
     afterImage =
        malloc(image_size(widthout, heightout, format, GL_UNSIGNED_SHORT));
     if (beforeImage == NULL || afterImage == NULL) {
+       free(beforeImage);
+       free(afterImage);
        return GLU_OUT_OF_MEMORY;
     }
 
@@ -3606,6 +3607,7 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
                    glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
                    glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
                    glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+                   free(newImage);
                    return GLU_OUT_OF_MEMORY;
                }
            }
@@ -3760,6 +3762,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
                    glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
                    glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
                    glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+                   free(newImage);
                    return GLU_OUT_OF_MEMORY;
                }
            }
@@ -4104,6 +4107,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
          glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
          glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+         free(srcImage);
          return GLU_OUT_OF_MEMORY;
        }
        /* level userLevel+1 is in srcImage; level userLevel already saved */
@@ -4346,6 +4350,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
            glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
            glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+           free(srcImage);
            return GLU_OUT_OF_MEMORY;
          }
        }
@@ -5547,7 +5552,7 @@ static void shove233rev(const GLfloat shoveComponents[],
 static void extract565(int isSwap,
                       const void *packedPixel, GLfloat extractComponents[])
 {
-   GLushort ushort= *(const GLushort *)packedPixel;
+   GLushort ushort;
 
    if (isSwap) {
      ushort= __GLU_SWAP_2_BYTES(packedPixel);
@@ -5588,7 +5593,7 @@ static void shove565(const GLfloat shoveComponents[],
 static void extract565rev(int isSwap,
                          const void *packedPixel, GLfloat extractComponents[])
 {
-   GLushort ushort= *(const GLushort *)packedPixel;
+   GLushort ushort;
 
    if (isSwap) {
      ushort= __GLU_SWAP_2_BYTES(packedPixel);
@@ -6626,7 +6631,7 @@ static TexImage3Dproc pTexImage3D = 0;
 #  include <dlfcn.h>
 #  include <sys/types.h>
 #else
-  WINGDIAPI PROC  WINAPI wglGetProcAddress(LPCSTR);
+#  include <windows.h>
 #endif
 
 static void gluTexImage3D( GLenum target, GLint level,
@@ -7382,6 +7387,8 @@ int gluScaleImage3D(GLenum format,
    afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format,
                                   GL_UNSIGNED_SHORT));
    if (beforeImage == NULL || afterImage == NULL) {
+       free(beforeImage);
+       free(afterImage);
        return GLU_OUT_OF_MEMORY;
    }
    retrieveStoreModes3D(&psm);
@@ -8093,6 +8100,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
         glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
         glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+        free(srcImage);
         return GLU_OUT_OF_MEMORY;
        }
        /* level userLevel+1 is in srcImage; level userLevel already saved */
@@ -8227,6 +8235,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
           glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
           glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+          free(srcImage);
           return GLU_OUT_OF_MEMORY;
         }
        }