Krolyxon
Commit 3b6db44

Branches

Refs →

nsxiv3b6db44

img_load_webp: remove unnecessary casting

Author
NRK
Date
2021-11-07 01:08 +0600
Committer
N-R-K · 2021-12-12 17:58 +0600
Parent
eccd7de
Commit
3b6db44267438fb0f9d67b3783d3bc6713c3c07f

+5 −7

1 file changed

  1. M image.c +5 −7
M image.c View
@@ -302,12 +302,11 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
302302 {
303303 FILE *webp_file;
304304 WebPData data;
305−
306305 Imlib_Image im = NULL;
307306 struct WebPAnimDecoderOptions opts;
308307 WebPAnimDecoder *dec = NULL;
309308 struct WebPAnimInfo info;
310− unsigned char *buf = NULL;
309+ unsigned char *buf = NULL, *bytes = NULL;
311310 int ts;
312311 const WebPDemuxer *demux;
313312 WebPIterator iter;
@@ -315,8 +314,6 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
315314 unsigned int delay;
316315 bool err = false;
317316
318− data.bytes = NULL;
319−
320317 if ((err = (webp_file = fopen(file->path, "rb")) == NULL)) {
321318 error(0, 0, "%s: Error opening webp image", file->name);
322319 goto fail;
@@ -324,11 +321,12 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
324321 fseek(webp_file, 0L, SEEK_END);
325322 data.size = ftell(webp_file);
326323 rewind(webp_file);
327− data.bytes = emalloc(data.size);
328− if ((err = fread((unsigned char *)data.bytes, 1, data.size, webp_file) != data.size)) {
324+ bytes = emalloc(data.size);
325+ if ((err = fread(bytes, 1, data.size, webp_file) != data.size)) {
329326 error(0, 0, "%s: Error reading webp image", file->name);
330327 goto fail;
331328 }
329+ data.bytes = bytes;
332330
333331 /* Setup the WebP Animation Decoder */
334332 if ((err = !WebPAnimDecoderOptionsInit(&opts))) {
@@ -391,7 +389,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
391389 fail:
392390 if (dec != NULL)
393391 WebPAnimDecoderDelete(dec);
394− free((unsigned char *)data.bytes);
392+ free(bytes);
395393 return !err;
396394 }
397395 #endif /* HAVE_LIBWEBP */