From 22ca3b567dd08c0086399221cb1413fa4eb74e2e Mon Sep 17 00:00:00 2001 From: NRK Date: Wed, 17 Nov 2021 06:32:51 +0600 Subject: 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. --- image.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/image.c b/image.c index 19fafaf..0dd39c7 100644 --- a/image.c +++ b/image.c @@ -348,10 +348,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) img->w = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); - if (img->multi.cap == 0) { - img->multi.cap = info.frame_count; - img->multi.frames = emalloc(img->multi.cap * sizeof(img_frame_t)); - } else if (info.frame_count > img->multi.cap) { + if (info.frame_count > img->multi.cap) { img->multi.cap = info.frame_count; img->multi.frames = erealloc(img->multi.frames, img->multi.cap * sizeof(img_frame_t)); -- cgit v1.2.3