diff options
author | NRK <nrk@disroot.org> | 2021-11-07 01:08:22 +0600 |
---|---|---|
committer | N-R-K <79544946+N-R-K@users.noreply.github.com> | 2021-12-12 17:58:17 +0600 |
commit | 3b6db44267438fb0f9d67b3783d3bc6713c3c07f (patch) | |
tree | 457052b7e61c8dec98747af943d94c86a61b234b | |
parent | eccd7de532b09fb738638095675eefc7be96ecc3 (diff) |
img_load_webp: remove unnecessary casting
-rw-r--r-- | image.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -302,12 +302,11 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) { FILE *webp_file; WebPData data; - Imlib_Image im = NULL; struct WebPAnimDecoderOptions opts; WebPAnimDecoder *dec = NULL; struct WebPAnimInfo info; - unsigned char *buf = NULL; + unsigned char *buf = NULL, *bytes = NULL; int ts; const WebPDemuxer *demux; WebPIterator iter; @@ -315,8 +314,6 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) unsigned int delay; bool err = false; - data.bytes = NULL; - if ((err = (webp_file = fopen(file->path, "rb")) == NULL)) { error(0, 0, "%s: Error opening webp image", file->name); goto fail; @@ -324,11 +321,12 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) fseek(webp_file, 0L, SEEK_END); data.size = ftell(webp_file); rewind(webp_file); - data.bytes = emalloc(data.size); - if ((err = fread((unsigned char *)data.bytes, 1, data.size, webp_file) != data.size)) { + bytes = emalloc(data.size); + if ((err = fread(bytes, 1, data.size, webp_file) != data.size)) { error(0, 0, "%s: Error reading webp image", file->name); goto fail; } + data.bytes = bytes; /* Setup the WebP Animation Decoder */ if ((err = !WebPAnimDecoderOptionsInit(&opts))) { @@ -391,7 +389,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) fail: if (dec != NULL) WebPAnimDecoderDelete(dec); - free((unsigned char *)data.bytes); + free(bytes); return !err; } #endif /* HAVE_LIBWEBP */ |