]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
replaced a loop that checked for alpha pixels with a call to Image_HasAlpha
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 May 2003 11:10:32 +0000 (11:10 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 May 2003 11:10:32 +0000 (11:10 +0000)
fixed a memory leak on s->maskpixels (due to memory pools this leak was probably not too bad)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2999 d7cf8633-e32d-0410-b094-e92efae38249

image.c

diff --git a/image.c b/image.c
index c3430f2276e0f00c6912e43649854d12bc76435d..8a46f44f52bc46267a162db89068fe97538b0aba 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1428,10 +1428,7 @@ int image_loadskin(imageskin_t *s, char *name)
        s->basepixels_height = image_height;
 
        bumppixels = NULL;bumppixels_width = 0;bumppixels_height = 0;
-       for (j = 3;j < s->basepixels_width * s->basepixels_height * 4;j += 4)
-               if (s->basepixels[j] < 255)
-                       break;
-       if (j < s->basepixels_width * s->basepixels_height * 4)
+       if (Image_HasAlpha(s->basepixels, s->basepixels_width * s->basepixels_height, true))
        {
                s->maskpixels = Mem_Alloc(loadmodel->mempool, s->basepixels_width * s->basepixels_height * 4);
                s->maskpixels_width = s->basepixels_width;
@@ -1513,6 +1510,8 @@ void image_freeskin(imageskin_t *s)
 {
        if (s->basepixels)
                Mem_Free(s->basepixels);
+       if (s->maskpixels)
+               Mem_Free(s->maskpixels);
        if (s->nmappixels)
                Mem_Free(s->nmappixels);
        if (s->glowpixels)