nsxiv22ca3b5
img_load_webp: simplify multi-frame allocation
C89 standard specifies: If ptr is a null pointer, the realloc function behaves like the malloc function for the specified size.
+1 −4
1 file changed
- M image.c +1 −4
| @@ -348,10 +348,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 348 | 348 | img->w = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); | |
| 349 | 349 | img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); | |
| 350 | 350 | ||
| 351 | − | if (img->multi.cap == 0) { | |
| 352 | − | img->multi.cap = info.frame_count; | |
| 353 | − | img->multi.frames = emalloc(img->multi.cap * sizeof(img_frame_t)); | |
| 354 | − | } else if (info.frame_count > img->multi.cap) { | |
| 351 | + | if (info.frame_count > img->multi.cap) { | |
| 355 | 352 | img->multi.cap = info.frame_count; | |
| 356 | 353 | img->multi.frames = erealloc(img->multi.frames, | |
| 357 | 354 | img->multi.cap * sizeof(img_frame_t)); | |