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.
This commit is contained in:
NRK 2021-11-17 06:32:51 +06:00 committed by N-R-K
parent 3b6db44267
commit 22ca3b567d

View File

@ -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->w = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
if (img->multi.cap == 0) { if (info.frame_count > img->multi.cap) {
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) {
img->multi.cap = info.frame_count; img->multi.cap = info.frame_count;
img->multi.frames = erealloc(img->multi.frames, img->multi.frames = erealloc(img->multi.frames,
img->multi.cap * sizeof(img_frame_t)); img->multi.cap * sizeof(img_frame_t));