nsxiv3b6db44
img_load_webp: remove unnecessary casting
+5 −7
1 file changed
- M image.c +5 −7
| @@ -302,12 +302,11 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 302 | 302 | { | |
| 303 | 303 | FILE *webp_file; | |
| 304 | 304 | WebPData data; | |
| 305 | − | ||
| 306 | 305 | Imlib_Image im = NULL; | |
| 307 | 306 | struct WebPAnimDecoderOptions opts; | |
| 308 | 307 | WebPAnimDecoder *dec = NULL; | |
| 309 | 308 | struct WebPAnimInfo info; | |
| 310 | − | unsigned char *buf = NULL; | |
| 309 | + | unsigned char *buf = NULL, *bytes = NULL; | |
| 311 | 310 | int ts; | |
| 312 | 311 | const WebPDemuxer *demux; | |
| 313 | 312 | WebPIterator iter; | |
| @@ -315,8 +314,6 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 315 | 314 | unsigned int delay; | |
| 316 | 315 | bool err = false; | |
| 317 | 316 | ||
| 318 | − | data.bytes = NULL; | |
| 319 | − | ||
| 320 | 317 | if ((err = (webp_file = fopen(file->path, "rb")) == NULL)) { | |
| 321 | 318 | error(0, 0, "%s: Error opening webp image", file->name); | |
| 322 | 319 | goto fail; | |
| @@ -324,11 +321,12 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 324 | 321 | fseek(webp_file, 0L, SEEK_END); | |
| 325 | 322 | data.size = ftell(webp_file); | |
| 326 | 323 | 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)) { | |
| 329 | 326 | error(0, 0, "%s: Error reading webp image", file->name); | |
| 330 | 327 | goto fail; | |
| 331 | 328 | } | |
| 329 | + | data.bytes = bytes; | |
| 332 | 330 | ||
| 333 | 331 | /* Setup the WebP Animation Decoder */ | |
| 334 | 332 | if ((err = !WebPAnimDecoderOptionsInit(&opts))) { | |
| @@ -391,7 +389,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 391 | 389 | fail: | |
| 392 | 390 | if (dec != NULL) | |
| 393 | 391 | WebPAnimDecoderDelete(dec); | |
| 394 | − | free((unsigned char *)data.bytes); | |
| 392 | + | free(bytes); | |
| 395 | 393 | return !err; | |
| 396 | 394 | } | |
| 397 | 395 | #endif /* HAVE_LIBWEBP */ | |