SDL_image: Removed unnecessary casts

From 338c8d229d64e4faed4af72a4b084ff0313fb58e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 19 Oct 2025 21:27:07 -0700
Subject: [PATCH] Removed unnecessary casts

---
 src/IMG_avif.c   |  6 +++---
 src/IMG_gif.c    | 32 ++++++++++++++------------------
 src/IMG_libpng.c | 20 ++++++++++----------
 src/IMG_qoi.c    |  2 +-
 src/IMG_webp.c   |  2 +-
 5 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index 76bed65b3..1face4286 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -1236,10 +1236,10 @@ static bool AnimationEncoder_AddFrame(struct IMG_AnimationEncoder *encoder, SDL_
         avifResult ar = lib.avifImageSetMetadataXMP(image, xmp_data, outlen);
         if (ar != AVIF_RESULT_OK) {
             lib.avifImageDestroy(image);
-            SDL_free((void *)xmp_data);
+            SDL_free(xmp_data);
             return SDL_SetError("Couldn't set XMP metadata for AVIF image: %s", lib.avifResultToString(ar));
         }
-        SDL_free((void *)xmp_data);
+        SDL_free(xmp_data);
     }
 
     image->yuvRange = AVIF_RANGE_FULL;
@@ -1617,7 +1617,7 @@ bool IMG_CreateAVIFAnimationEncoder(IMG_AnimationEncoder *encoder, SDL_Propertie
         if (!SDL_CopyProperties(props, ctx->metadata)) {
             lib.avifEncoderDestroy(ctx->encoder);
             SDL_DestroyProperties(ctx->metadata);
-            SDL_free((void *)ctx);
+            SDL_free(ctx);
             return SDL_SetError("Couldn't copy properties to AVIF encoder metadata");
         }
     }
diff --git a/src/IMG_gif.c b/src/IMG_gif.c
index 86f46e955..c786ae829 100644
--- a/src/IMG_gif.c
+++ b/src/IMG_gif.c
@@ -410,9 +410,9 @@ ReadImage(SDL_IOStream * src, int len, int height, int cmapSize,
     Uint8 *dst;
     int pixel_count = 0;
     int total_pixels = len * height;
-    
+
     (void) gray; /* unused */
-    
+
     if (!ReadOK(src, &c, 1)) {
         RWSetMsg("EOF / read error on image data");
         return NULL;
@@ -421,28 +421,28 @@ ReadImage(SDL_IOStream * src, int len, int height, int cmapSize,
         RWSetMsg("error reading image");
         return NULL;
     }
-    
+
     if (ignore) {
         while (LWZReadByte(src, FALSE, c, state) >= 0)
             ;
         return NULL;
     }
-    
+
     /* Create RGBA32 surface with frame dimensions */
     image = SDL_CreateSurface(len, height, SDL_PIXELFORMAT_RGBA32);
     if (!image) {
         return NULL;
     }
-    
+
     /* Initialize entire surface to transparent */
     SDL_memset(image->pixels, 0, image->pitch * height);
-    
+
     transparent_index = state->Gif89.transparent;
-    
+
     /* Decode and convert to RGBA */
     while ((v = LWZReadByte(src, FALSE, c, state)) >= 0 && pixel_count < total_pixels) {
         dst = (Uint8 *)image->pixels + (ypos * image->pitch) + (xpos * 4);
-        
+
         /* Only write non-transparent pixels */
         if (transparent_index < 0 || v != transparent_index) {
             if (v < cmapSize) {
@@ -458,7 +458,7 @@ ReadImage(SDL_IOStream * src, int len, int height, int cmapSize,
                 dst[3] = 255;
             }
         }
-        
+
         pixel_count++;
         ++xpos;
         if (xpos == len) {
@@ -499,7 +499,7 @@ ReadImage(SDL_IOStream * src, int len, int height, int cmapSize,
         if (ypos >= height)
             break;
     }
-    
+
 fini:
     return image;
 }
@@ -581,7 +581,7 @@ static bool IMG_AnimationDecoderReset_Internal(IMG_AnimationDecoder *decoder)
     return true;
 }
 
-static bool IMG_AnimationDecoderGetGIFHeader(IMG_AnimationDecoder *decoder, const char** comment, int* loopCount)
+static bool IMG_AnimationDecoderGetGIFHeader(IMG_AnimationDecoder *decoder, char**comment, int *loopCount)
 {
     if (comment) {
         *comment = NULL;
@@ -725,7 +725,7 @@ static bool IMG_AnimationDecoderGetGIFHeader(IMG_AnimationDecoder *decoder, cons
                                 c[current_len] = '\0';
                             }
 
-                            *comment = (const char *)c;
+                            *comment = c;
                         }
                     } break;
 
@@ -998,7 +998,7 @@ bool IMG_CreateGIFAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Properties
     decoder->GetNextFrame = IMG_AnimationDecoderGetNextFrame_Internal;
     decoder->Close = IMG_AnimationDecoderClose_Internal;
 
-    const char *comment;
+    char *comment = NULL;
     int loop_count = 0;
     if (!IMG_AnimationDecoderGetGIFHeader(decoder, &comment, &loop_count)) {
         return false;
@@ -1015,11 +1015,7 @@ bool IMG_CreateGIFAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Properties
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_DESCRIPTION_STRING, comment);
         }
     }
-
-    if (comment) {
-        SDL_free((void *)comment);
-        comment = NULL;
-    }
+    SDL_free(comment);
 
     return true;
 }
diff --git a/src/IMG_libpng.c b/src/IMG_libpng.c
index 6dd9e5db7..82b138fce 100644
--- a/src/IMG_libpng.c
+++ b/src/IMG_libpng.c
@@ -1351,11 +1351,11 @@ bool IMG_CreateAPNGAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Propertie
     }
 
     // Extracted metadata will be assigned to variables below
-    const char *desc = NULL;
-    const char *rights = NULL;
-    const char *title = NULL;
-    const char *author = NULL;
-    const char *creationtime = NULL;
+    char *desc = NULL;
+    char *rights = NULL;
+    char *title = NULL;
+    char *author = NULL;
+    char *creationtime = NULL;
 
     bool found_iend = false;
     while (!found_iend) {
@@ -1665,23 +1665,23 @@ bool IMG_CreateAPNGAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Propertie
         // Get other well-defined properties and set them in our props.
         if (desc) {
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_DESCRIPTION_STRING, desc);
-            SDL_free((void *)desc);
+            SDL_free(desc);
         }
         if (rights) {
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_COPYRIGHT_STRING, rights);
-            SDL_free((void *)rights);
+            SDL_free(rights);
         }
         if (title) {
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_TITLE_STRING, title);
-            SDL_free((void *)title);
+            SDL_free(title);
         }
         if (author) {
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_AUTHOR_STRING, author);
-            SDL_free((void *)author);
+            SDL_free(author);
         }
         if (creationtime) {
             SDL_SetStringProperty(decoder->props, IMG_PROP_METADATA_CREATION_TIME_STRING, creationtime);
-            SDL_free((void *)creationtime);
+            SDL_free(creationtime);
         }
     }
 
diff --git a/src/IMG_qoi.c b/src/IMG_qoi.c
index 6bbde1649..d9e1e2d4a 100644
--- a/src/IMG_qoi.c
+++ b/src/IMG_qoi.c
@@ -72,7 +72,7 @@ SDL_Surface *IMG_LoadQOI_IO(SDL_IOStream *src)
     qoi_desc image_info;
     SDL_Surface *surface = NULL;
 
-    data = (void *)SDL_LoadFile_IO(src, &size, false);
+    data = SDL_LoadFile_IO(src, &size, false);
     if ( !data ) {
         return NULL;
     }
diff --git a/src/IMG_webp.c b/src/IMG_webp.c
index 737cc1405..0ad1982e1 100644
--- a/src/IMG_webp.c
+++ b/src/IMG_webp.c
@@ -971,7 +971,7 @@ static bool IMG_CloseWEBPAnimation(IMG_AnimationEncoder *encoder)
             goto done;
         }
 
-        SDL_free((void *)d);
+        SDL_free(d);
 
         muxErr = lib.WebPMuxAssemble(mux, &data);
         if (muxErr != WEBP_MUX_OK) {