Krolyxon
Commit 22ca3b5

Branches

Refs →

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.
Author
NRK
Date
2021-11-17 06:32 +0600
Committer
N-R-K · 2021-12-12 17:58 +0600
Parent
3b6db44
Commit
22ca3b567dd08c0086399221cb1413fa4eb74e2e

+1 −4

1 file changed

  1. M image.c +1 −4
M image.c View
@@ -348,10 +348,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
348348 img->w = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
349349 img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
350350
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) {
355352 img->multi.cap = info.frame_count;
356353 img->multi.frames = erealloc(img->multi.frames,
357354 img->multi.cap * sizeof(img_frame_t));