[FFmpeg-devel] [PATCH 11/12] Replace all occurences of av_mallocz_array() by av_calloc()
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Sep 15 03:57:44 EEST 2021
They do the same.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
compat/w32dlfcn.h | 2 +-
doc/examples/remuxing.c | 2 +-
doc/examples/transcoding.c | 2 +-
fftools/cmdutils.c | 4 +--
fftools/ffmpeg_opt.c | 8 +++---
fftools/ffprobe.c | 3 +--
libavcodec/a64multienc.c | 4 +--
libavcodec/aacpsy.c | 2 +-
libavcodec/alsdec.c | 15 +++++------
libavcodec/atrac3.c | 2 +-
libavcodec/atrac3plusdec.c | 2 +-
libavcodec/cavs.c | 16 +++++------
libavcodec/cfhd.c | 4 +--
libavcodec/cfhdenc.c | 2 +-
libavcodec/cngdec.c | 10 +++----
libavcodec/decode.c | 4 +--
libavcodec/diracdec.c | 2 +-
libavcodec/dnxhddec.c | 2 +-
libavcodec/dvbsubdec.c | 2 +-
libavcodec/dxva2.c | 2 +-
libavcodec/exr.c | 2 +-
libavcodec/ffv1.c | 2 +-
libavcodec/g2meet.c | 2 +-
libavcodec/h264dec.c | 2 +-
libavcodec/hevcdec.c | 8 +++---
libavcodec/ivi.c | 6 ++---
libavcodec/j2kenc.c | 4 +--
libavcodec/jpeg2000.c | 16 +++++------
libavcodec/jpeg2000dec.c | 4 +--
libavcodec/libopencore-amr.c | 4 +--
libavcodec/libopusenc.c | 2 +-
libavcodec/libvpxenc.c | 2 +-
libavcodec/libx264.c | 2 +-
libavcodec/libx265.c | 2 +-
libavcodec/libxavs.c | 2 +-
libavcodec/mjpegdec.c | 4 +--
libavcodec/mlz.c | 2 +-
libavcodec/motionpixels.c | 6 ++---
libavcodec/nvenc.c | 2 +-
libavcodec/omx.c | 2 +-
libavcodec/opus.c | 2 +-
libavcodec/opusdec.c | 2 +-
libavcodec/pgssubdec.c | 2 +-
libavcodec/png.c | 2 +-
libavcodec/proresdec2.c | 2 +-
libavcodec/psymodel.c | 6 ++---
libavcodec/pthread_frame.c | 2 +-
libavcodec/pthread_slice.c | 2 +-
libavcodec/qsv.c | 4 +--
libavcodec/qsvenc.c | 4 +--
libavcodec/qtrleenc.c | 2 +-
libavcodec/roqvideoenc.c | 4 +--
libavcodec/snow.c | 5 ++--
libavcodec/snow_dwt.c | 2 +-
libavcodec/snowenc.c | 6 ++---
libavcodec/svq3.c | 2 +-
libavcodec/tests/snowenc.c | 4 +--
libavcodec/tiff.c | 2 +-
libavcodec/tta.c | 3 ++-
libavcodec/utils.c | 3 +--
libavcodec/vaapi_encode.c | 4 +--
libavcodec/vorbisdec.c | 8 +++---
libavcodec/vorbisenc.c | 4 +--
libavcodec/vp3.c | 16 +++++------
libavcodec/vp9.c | 2 +-
libavcodec/webp.c | 10 +++----
libavfilter/af_amix.c | 8 +++---
libavfilter/af_channelmap.c | 2 +-
libavfilter/af_compand.c | 4 +--
libavfilter/af_join.c | 14 +++++-----
libavfilter/af_silencedetect.c | 3 ++-
libavfilter/avf_showwaves.c | 4 +--
libavfilter/avfilter.c | 4 +--
libavfilter/dnn/dnn_backend_tf.c | 2 +-
libavfilter/dnn_filter_common.c | 2 +-
libavfilter/ebur128.c | 6 ++---
libavfilter/framepool.c | 8 +++---
libavfilter/qsvvpp.c | 12 ++++-----
libavfilter/tests/integral.c | 4 +--
libavfilter/vf_colorconstancy.c | 5 ++--
libavfilter/vf_coreimage.m | 2 +-
libavfilter/vf_curves.c | 2 +-
libavfilter/vf_deinterlace_qsv.c | 8 +++---
libavfilter/vf_dejudder.c | 2 +-
libavfilter/vf_libopencv.c | 2 +-
libavfilter/vf_mestimate.c | 2 +-
libavfilter/vf_minterpolate.c | 14 +++++-----
libavfilter/vf_nlmeans.c | 2 +-
libavfilter/vf_overlay_qsv.c | 4 +--
libavfilter/vf_program_opencl.c | 3 +--
libavfilter/vf_scale_qsv.c | 16 +++++------
libavfilter/vf_ssim.c | 2 +-
libavfilter/vf_unsharp.c | 2 +-
libavfilter/vf_yaepblur.c | 4 +--
libavfilter/vsrc_cellauto.c | 4 +--
libavformat/avidec.c | 2 +-
libavformat/hashenc.c | 6 ++---
libavformat/hdsenc.c | 2 +-
libavformat/icoenc.c | 2 +-
libavformat/matroskaenc.c | 2 +-
libavformat/mov.c | 6 ++---
libavformat/movenc.c | 2 +-
libavformat/mxfdec.c | 8 +++---
libavformat/protocols.c | 2 +-
libavformat/rtspdec.c | 2 +-
libavformat/sapenc.c | 2 +-
libavformat/smoothstreamingenc.c | 2 +-
libavformat/tee.c | 2 +-
libavformat/utils.c | 4 +--
libavformat/wavenc.c | 4 +--
libavformat/xmv.c | 2 +-
libavutil/audio_fifo.c | 2 +-
libavutil/encryption_info.c | 4 +--
libavutil/frame.c | 8 +++---
libavutil/hwcontext.c | 2 +-
libavutil/hwcontext_d3d11va.c | 2 +-
libavutil/hwcontext_dxva2.c | 4 +--
libavutil/hwcontext_opencl.c | 8 +++---
libavutil/hwcontext_qsv.c | 43 ++++++++++++++++--------------
libavutil/hwcontext_vulkan.c | 4 +--
libavutil/internal.h | 2 +-
libavutil/wchar_filename.h | 2 +-
libswresample/swresample.c | 2 +-
libswresample/x86/rematrix_init.c | 4 +--
libswscale/slice.c | 6 ++---
libswscale/utils.c | 4 +--
libswscale/vscale.c | 2 +-
tests/api/api-threadmessage-test.c | 4 +--
tests/checkasm/llviddsp.c | 24 ++++++++---------
tests/checkasm/vf_nlmeans.c | 6 ++---
tools/ismindex.c | 2 +-
131 files changed, 302 insertions(+), 301 deletions(-)
diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h
index c83bdc9333..52a94efafb 100644
--- a/compat/w32dlfcn.h
+++ b/compat/w32dlfcn.h
@@ -42,7 +42,7 @@ static inline HMODULE win32_dlopen(const char *name)
DWORD pathlen;
if (utf8towchar(name, &name_w))
goto exit;
- path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t));
+ path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
// Try local directory first
pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
pathlen = wcsrchr(path, '\\') - path;
diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c
index 13313a1748..fbf6de0cae 100644
--- a/doc/examples/remuxing.c
+++ b/doc/examples/remuxing.c
@@ -85,7 +85,7 @@ int main(int argc, char **argv)
}
stream_mapping_size = ifmt_ctx->nb_streams;
- stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
+ stream_mapping = av_calloc(stream_mapping_size, sizeof(*stream_mapping));
if (!stream_mapping) {
ret = AVERROR(ENOMEM);
goto end;
diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index 51c120dfb7..badfba62cb 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -72,7 +72,7 @@ static int open_input_file(const char *filename)
return ret;
}
- stream_ctx = av_mallocz_array(ifmt_ctx->nb_streams, sizeof(*stream_ctx));
+ stream_ctx = av_calloc(ifmt_ctx->nb_streams, sizeof(*stream_ctx));
if (!stream_ctx)
return AVERROR(ENOMEM);
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index abf56c4567..ff50577a74 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -689,7 +689,7 @@ static void init_parse_context(OptionParseContext *octx,
memset(octx, 0, sizeof(*octx));
octx->nb_groups = nb_groups;
- octx->groups = av_mallocz_array(octx->nb_groups, sizeof(*octx->groups));
+ octx->groups = av_calloc(octx->nb_groups, sizeof(*octx->groups));
if (!octx->groups)
exit_program(1);
@@ -2168,7 +2168,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
if (!s->nb_streams)
return NULL;
- opts = av_mallocz_array(s->nb_streams, sizeof(*opts));
+ opts = av_calloc(s->nb_streams, sizeof(*opts));
if (!opts) {
av_log(NULL, AV_LOG_ERROR,
"Could not alloc memory for stream options.\n");
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 6ca28cf974..8c1d96ccf8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2591,7 +2591,7 @@ loop_end:
count = 0;
while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE)
count++;
- f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
+ f->formats = av_calloc(count + 1, sizeof(*f->formats));
if (!f->formats)
exit_program(1);
memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats));
@@ -2604,7 +2604,7 @@ loop_end:
count = 0;
while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE)
count++;
- f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
+ f->formats = av_calloc(count + 1, sizeof(*f->formats));
if (!f->formats)
exit_program(1);
memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats));
@@ -2615,7 +2615,7 @@ loop_end:
count = 0;
while (ost->enc->supported_samplerates[count])
count++;
- f->sample_rates = av_mallocz_array(count + 1, sizeof(*f->sample_rates));
+ f->sample_rates = av_calloc(count + 1, sizeof(*f->sample_rates));
if (!f->sample_rates)
exit_program(1);
memcpy(f->sample_rates, ost->enc->supported_samplerates,
@@ -2627,7 +2627,7 @@ loop_end:
count = 0;
while (ost->enc->channel_layouts[count])
count++;
- f->channel_layouts = av_mallocz_array(count + 1, sizeof(*f->channel_layouts));
+ f->channel_layouts = av_calloc(count + 1, sizeof(*f->channel_layouts));
if (!f->channel_layouts)
exit_program(1);
memcpy(f->channel_layouts, ost->enc->channel_layouts,
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index d8e968321e..90e895bbf9 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3003,8 +3003,7 @@ static int open_input_file(InputFile *ifile, const char *filename,
av_dump_format(fmt_ctx, 0, filename, 0);
- ifile->streams = av_mallocz_array(fmt_ctx->nb_streams,
- sizeof(*ifile->streams));
+ ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
if (!ifile->streams)
exit(1);
ifile->nb_streams = fmt_ctx->nb_streams;
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index e2dd85b756..99df55dc7b 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -227,9 +227,9 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx)
a64_palette[mc_colors[a]][2] * 0.11;
}
- if (!(c->mc_meta_charset = av_mallocz_array(c->mc_lifetime, 32000 * sizeof(int))) ||
+ if (!(c->mc_meta_charset = av_calloc(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
- !(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
+ !(c->mc_charmap = av_calloc(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
return AVERROR(ENOMEM);
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 487b84fd85..0c64f2c7b0 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -370,7 +370,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
}
}
- pctx->ch = av_mallocz_array(ctx->avctx->channels, sizeof(AacPsyChannel));
+ pctx->ch = av_calloc(ctx->avctx->channels, sizeof(*pctx->ch));
if (!pctx->ch) {
av_freep(&ctx->model_priv_data);
return AVERROR(ENOMEM);
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index ba873ec53a..9e1aaf065a 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -2059,7 +2059,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ctx->shift_lsbs = av_malloc_array(num_buffers, sizeof(*ctx->shift_lsbs));
ctx->opt_order = av_malloc_array(num_buffers, sizeof(*ctx->opt_order));
ctx->store_prev_samples = av_malloc_array(num_buffers, sizeof(*ctx->store_prev_samples));
- ctx->use_ltp = av_mallocz_array(num_buffers, sizeof(*ctx->use_ltp));
+ ctx->use_ltp = av_calloc(num_buffers, sizeof(*ctx->use_ltp));
ctx->ltp_lag = av_malloc_array(num_buffers, sizeof(*ctx->ltp_lag));
ctx->ltp_gain = av_malloc_array(num_buffers, sizeof(*ctx->ltp_gain));
ctx->ltp_gain_buffer = av_malloc_array(num_buffers * 5, sizeof(*ctx->ltp_gain_buffer));
@@ -2078,10 +2078,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
// allocate and assign channel data buffer for mcc mode
if (sconf->mc_coding) {
- ctx->chan_data_buffer = av_mallocz_array(num_buffers * num_buffers,
- sizeof(*ctx->chan_data_buffer));
- ctx->chan_data = av_mallocz_array(num_buffers,
- sizeof(*ctx->chan_data));
+ ctx->chan_data_buffer = av_calloc(num_buffers * num_buffers,
+ sizeof(*ctx->chan_data_buffer));
+ ctx->chan_data = av_calloc(num_buffers, sizeof(*ctx->chan_data));
ctx->reverted_channels = av_malloc_array(num_buffers,
sizeof(*ctx->reverted_channels));
@@ -2102,7 +2101,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
channel_size = sconf->frame_length + sconf->max_order;
ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
- ctx->raw_buffer = av_mallocz_array(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
+ ctx->raw_buffer = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
ctx->raw_samples = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
if (sconf->floating) {
@@ -2110,7 +2109,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ctx->shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value));
ctx->last_shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->last_shift_value));
ctx->last_acf_mantissa = av_malloc_array(avctx->channels, sizeof(*ctx->last_acf_mantissa));
- ctx->raw_mantissa = av_mallocz_array(avctx->channels, sizeof(*ctx->raw_mantissa));
+ ctx->raw_mantissa = av_calloc(avctx->channels, sizeof(*ctx->raw_mantissa));
ctx->larray = av_malloc_array(ctx->cur_frame_length * 4, sizeof(*ctx->larray));
ctx->nbits = av_malloc_array(ctx->cur_frame_length, sizeof(*ctx->nbits));
@@ -2127,7 +2126,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_mlz_flush_dict(ctx->mlz);
for (c = 0; c < avctx->channels; ++c) {
- ctx->raw_mantissa[c] = av_mallocz_array(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa));
+ ctx->raw_mantissa[c] = av_calloc(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa));
}
}
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index b4809111f8..2376a7cd02 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -1004,7 +1004,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
q->vector_fmul = fdsp->vector_fmul;
av_free(fdsp);
- q->units = av_mallocz_array(avctx->channels, sizeof(*q->units));
+ q->units = av_calloc(avctx->channels, sizeof(*q->units));
if (!q->units)
return AVERROR(ENOMEM);
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index 9917f2d819..e342f09fdb 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -175,7 +175,7 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
ctx->my_channel_layout = avctx->channel_layout;
- ctx->ch_units = av_mallocz_array(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
+ ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!ctx->ch_units || !ctx->fdsp) {
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 74b8371501..e29d9c659b 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -762,16 +762,16 @@ int ff_cavs_init_top_lines(AVSContext *h)
{
/* alloc top line of predictors */
h->top_qp = av_mallocz(h->mb_width);
- h->top_mv[0] = av_mallocz_array(h->mb_width * 2 + 1, sizeof(cavs_vector));
- h->top_mv[1] = av_mallocz_array(h->mb_width * 2 + 1, sizeof(cavs_vector));
- h->top_pred_Y = av_mallocz_array(h->mb_width * 2, sizeof(*h->top_pred_Y));
- h->top_border_y = av_mallocz_array(h->mb_width + 1, 16);
- h->top_border_u = av_mallocz_array(h->mb_width, 10);
- h->top_border_v = av_mallocz_array(h->mb_width, 10);
+ h->top_mv[0] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
+ h->top_mv[1] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
+ h->top_pred_Y = av_calloc(h->mb_width * 2, sizeof(*h->top_pred_Y));
+ h->top_border_y = av_calloc(h->mb_width + 1, 16);
+ h->top_border_u = av_calloc(h->mb_width, 10);
+ h->top_border_v = av_calloc(h->mb_width, 10);
/* alloc space for co-located MVs and types */
- h->col_mv = av_mallocz_array(h->mb_width * h->mb_height,
- 4 * sizeof(cavs_vector));
+ h->col_mv = av_calloc(h->mb_width * h->mb_height,
+ 4 * sizeof(*h->col_mv));
h->col_type_base = av_mallocz(h->mb_width * h->mb_height);
h->block = av_mallocz(64 * sizeof(int16_t));
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 66e1695ec9..008a6360b6 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -290,13 +290,13 @@ static int alloc_buffers(AVCodecContext *avctx)
if (s->transform_type == 0) {
s->plane[i].idwt_size = FFALIGN(height, 8) * stride;
s->plane[i].idwt_buf =
- av_mallocz_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
+ av_calloc(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
s->plane[i].idwt_tmp =
av_malloc_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_tmp));
} else {
s->plane[i].idwt_size = FFALIGN(height, 8) * stride * 2;
s->plane[i].idwt_buf =
- av_mallocz_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
+ av_calloc(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
s->plane[i].idwt_tmp =
av_malloc_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_tmp));
}
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 38e4acb4f0..3d87064a40 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -280,7 +280,7 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
h2 = h4 * 2;
s->plane[i].dwt_buf =
- av_mallocz_array(height * stride, sizeof(*s->plane[i].dwt_buf));
+ av_calloc(height * stride, sizeof(*s->plane[i].dwt_buf));
s->plane[i].dwt_tmp =
av_malloc_array(height * stride, sizeof(*s->plane[i].dwt_tmp));
if (!s->plane[i].dwt_buf || !s->plane[i].dwt_tmp)
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index 57cb620179..ecfd4abfc9 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -61,12 +61,12 @@ static av_cold int cng_decode_init(AVCodecContext *avctx)
p->order = 12;
avctx->frame_size = 640;
- p->refl_coef = av_mallocz_array(p->order, sizeof(*p->refl_coef));
- p->target_refl_coef = av_mallocz_array(p->order, sizeof(*p->target_refl_coef));
- p->lpc_coef = av_mallocz_array(p->order, sizeof(*p->lpc_coef));
- p->filter_out = av_mallocz_array(avctx->frame_size + p->order,
+ p->refl_coef = av_calloc(p->order, sizeof(*p->refl_coef));
+ p->target_refl_coef = av_calloc(p->order, sizeof(*p->target_refl_coef));
+ p->lpc_coef = av_calloc(p->order, sizeof(*p->lpc_coef));
+ p->filter_out = av_calloc(avctx->frame_size + p->order,
sizeof(*p->filter_out));
- p->excitation = av_mallocz_array(avctx->frame_size, sizeof(*p->excitation));
+ p->excitation = av_calloc(avctx->frame_size, sizeof(*p->excitation));
if (!p->refl_coef || !p->target_refl_coef || !p->lpc_coef ||
!p->filter_out || !p->excitation) {
return AVERROR(ENOMEM);
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 023dd3c0b2..294c040716 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1370,9 +1370,9 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
frame->linesize[0] = pool->linesize[0];
if (planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data));
+ frame->extended_data = av_calloc(planes, sizeof(*frame->extended_data));
frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
- frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
+ frame->extended_buf = av_calloc(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf) {
av_freep(&frame->extended_data);
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 1113517880..7ffb8a3496 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -304,7 +304,7 @@ static int alloc_sequence_buffers(DiracContext *s)
w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
- s->plane[i].idwt.buf_base = av_mallocz_array((w+max_xblen), h * (2 << s->pshift));
+ s->plane[i].idwt.buf_base = av_calloc(w + max_xblen, h * (2 << s->pshift));
s->plane[i].idwt.tmp = av_malloc_array((w+16), 2 << s->pshift);
s->plane[i].idwt.buf = s->plane[i].idwt.buf_base + (top_padding*w)*(2 << s->pshift);
if (!s->plane[i].idwt.buf_base || !s->plane[i].idwt.tmp)
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index d113c1db7b..9ecd220e7f 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -103,7 +103,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
avctx->coded_width = FFALIGN(avctx->width, 16);
avctx->coded_height = FFALIGN(avctx->height, 16);
- ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext));
+ ctx->rows = av_calloc(avctx->thread_count, sizeof(*ctx->rows));
if (!ctx->rows)
return AVERROR(ENOMEM);
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index e45c14e878..d192f3251d 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -764,7 +764,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou
}
if (sub->num_rects > 0) {
- sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects);
+ sub->rects = av_calloc(sub->num_rects, sizeof(*sub->rects));
if (!sub->rects) {
ret = AVERROR(ENOMEM);
goto fail;
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index b57ea21941..568d686f39 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -515,7 +515,7 @@ static int d3d11va_create_decoder(AVCodecContext *avctx)
if (ret < 0)
return AVERROR(EINVAL);
- sctx->d3d11_views = av_mallocz_array(texdesc.ArraySize, sizeof(sctx->d3d11_views[0]));
+ sctx->d3d11_views = av_calloc(texdesc.ArraySize, sizeof(sctx->d3d11_views[0]));
if (!sctx->d3d11_views)
return AVERROR(ENOMEM);
sctx->nb_d3d11_views = texdesc.ArraySize;
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 66b7e258ee..0d5b3467d1 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -2253,7 +2253,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
// allocate thread data, used for non EXR_RAW compression types
- s->thread_data = av_mallocz_array(avctx->thread_count, sizeof(EXRThreadData));
+ s->thread_data = av_calloc(avctx->thread_count, sizeof(*s->thread_data));
if (!s->thread_data)
return AVERROR(ENOMEM);
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 1c580c3b49..a27eca5ae3 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -80,7 +80,7 @@ av_cold int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
return AVERROR(ENOMEM);
} else {
if (!p->vlc_state) {
- p->vlc_state = av_mallocz_array(p->context_count, sizeof(VlcState));
+ p->vlc_state = av_calloc(p->context_count, sizeof(*p->vlc_state));
if (!p->vlc_state)
return AVERROR(ENOMEM);
for (i = 0; i < p->context_count; i++) {
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 66f4557f06..c9e8d11ab8 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -1164,7 +1164,7 @@ static int g2m_init_buffers(G2MContext *c)
c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
aligned_height = c->height + 15;
av_free(c->framebuf);
- c->framebuf = av_mallocz_array(c->framebuf_stride, aligned_height);
+ c->framebuf = av_calloc(c->framebuf_stride, aligned_height);
if (!c->framebuf)
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index c7e8b2827b..5ca41cc91c 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -314,7 +314,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
ff_h264_sei_uninit(&h->sei);
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1;
- h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
+ h->slice_ctx = av_calloc(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index eafb883429..57a61752a3 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -99,8 +99,8 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
s->bs_width = (width >> 2) + 1;
s->bs_height = (height >> 2) + 1;
- s->sao = av_mallocz_array(ctb_count, sizeof(*s->sao));
- s->deblock = av_mallocz_array(ctb_count, sizeof(*s->deblock));
+ s->sao = av_calloc(ctb_count, sizeof(*s->sao));
+ s->deblock = av_calloc(ctb_count, sizeof(*s->deblock));
if (!s->sao || !s->deblock)
goto fail;
@@ -123,8 +123,8 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
goto fail;
- s->horizontal_bs = av_mallocz_array(s->bs_width, s->bs_height);
- s->vertical_bs = av_mallocz_array(s->bs_width, s->bs_height);
+ s->horizontal_bs = av_calloc(s->bs_width, s->bs_height);
+ s->vertical_bs = av_calloc(s->bs_width, s->bs_height);
if (!s->horizontal_bs || !s->vertical_bs)
goto fail;
diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index cefaf77bfd..77979d04e7 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -313,7 +313,7 @@ av_cold int ff_ivi_init_planes(AVCodecContext *avctx, IVIPlaneDesc *planes, cons
planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
for (p = 0; p < 3; p++) {
- planes[p].bands = av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
+ planes[p].bands = av_calloc(planes[p].num_bands, sizeof(*planes[p].bands));
if (!planes[p].bands)
return AVERROR(ENOMEM);
@@ -372,7 +372,7 @@ static int ivi_init_tiles(const IVIBandDesc *band, IVITile *ref_tile,
band->mb_size);
av_freep(&tile->mbs);
- tile->mbs = av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
+ tile->mbs = av_calloc(tile->num_MBs, sizeof(*tile->mbs));
if (!tile->mbs)
return AVERROR(ENOMEM);
@@ -428,7 +428,7 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
band->num_tiles = x_tiles * y_tiles;
av_freep(&band->tiles);
- band->tiles = av_mallocz_array(band->num_tiles, sizeof(IVITile));
+ band->tiles = av_calloc(band->num_tiles, sizeof(*band->tiles));
if (!band->tiles) {
band->num_tiles = 0;
return AVERROR(ENOMEM);
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 83f7d6efbf..7ebd6856e0 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -468,11 +468,11 @@ static int init_tiles(Jpeg2000EncoderContext *s)
for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){
Jpeg2000Tile *tile = s->tile + tileno;
- tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component));
+ tile->comp = av_calloc(s->ncomponents, sizeof(*tile->comp));
if (!tile->comp)
return AVERROR(ENOMEM);
- tile->layer_rates = av_mallocz_array(s->nlayers, sizeof(*tile->layer_rates));
+ tile->layer_rates = av_calloc(s->nlayers, sizeof(*tile->layer_rates));
if (!tile->layer_rates)
return AVERROR(ENOMEM);
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 2fbdb64280..0aa984bc53 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -60,7 +60,7 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h)
tt_size = tag_tree_size(w, h);
- t = res = av_mallocz_array(tt_size, sizeof(*t));
+ t = res = av_calloc(tt_size, sizeof(*t));
if (!res)
return NULL;
@@ -333,7 +333,7 @@ static int init_prec(AVCodecContext *avctx,
return AVERROR(ENOMEM);
}
nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
- prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
+ prec->cblk = av_calloc(nb_codeblocks, sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
@@ -376,7 +376,7 @@ static int init_prec(AVCodecContext *avctx,
cblk->length = 0;
cblk->npasses = 0;
if (av_codec_is_encoder(avctx->codec)) {
- cblk->layers = av_mallocz_array(codsty->nlayers, sizeof(*cblk->layers));
+ cblk->layers = av_calloc(codsty->nlayers, sizeof(*cblk->layers));
if (!cblk->layers)
return AVERROR(ENOMEM);
}
@@ -448,7 +448,7 @@ static int init_band(AVCodecContext *avctx,
return AVERROR(ENOMEM);
}
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
- band->prec = av_mallocz_array(nb_precincts, sizeof(*band->prec));
+ band->prec = av_calloc(nb_precincts, sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
@@ -496,17 +496,17 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
if (codsty->transform == FF_DWT97) {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data);
comp->i_data = NULL;
- comp->f_data = av_mallocz_array(csize, sizeof(*comp->f_data));
+ comp->f_data = av_calloc(csize, sizeof(*comp->f_data));
if (!comp->f_data)
return AVERROR(ENOMEM);
} else {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->i_data);
comp->f_data = NULL;
- comp->i_data = av_mallocz_array(csize, sizeof(*comp->i_data));
+ comp->i_data = av_calloc(csize, sizeof(*comp->i_data));
if (!comp->i_data)
return AVERROR(ENOMEM);
}
- comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel));
+ comp->reslevel = av_calloc(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
/* LOOP on resolution levels */
@@ -554,7 +554,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
- reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band));
+ reslevel->band = av_calloc(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c95f22bc90..80b2e2d627 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -361,7 +361,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
return AVERROR(EINVAL);
}
- s->tile = av_mallocz_array(s->numXtiles * s->numYtiles, sizeof(*s->tile));
+ s->tile = av_calloc(s->numXtiles * s->numYtiles, sizeof(*s->tile));
if (!s->tile) {
s->numXtiles = s->numYtiles = 0;
return AVERROR(ENOMEM);
@@ -1176,7 +1176,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
cblk->nb_lengthinc = 0;
cblk->nb_terminationsinc = 0;
av_free(cblk->lengthinc);
- cblk->lengthinc = av_mallocz_array(newpasses , sizeof(*cblk->lengthinc));
+ cblk->lengthinc = av_calloc(newpasses, sizeof(*cblk->lengthinc));
if (!cblk->lengthinc)
return AVERROR(ENOMEM);
tmp = av_realloc_array(cblk->data_start, cblk->nb_terminations + newpasses + 1, sizeof(*cblk->data_start));
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
index f2cbc6eeb1..2df1c5090f 100644
--- a/libavcodec/libopencore-amr.c
+++ b/libavcodec/libopencore-amr.c
@@ -249,7 +249,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (frame) {
if (frame->nb_samples < avctx->frame_size) {
- flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
+ flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
memcpy(flush_buf, samples, frame->nb_samples * sizeof(*flush_buf));
@@ -264,7 +264,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
} else {
if (s->enc_last_frame < 0)
return 0;
- flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
+ flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
samples = flush_buf;
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 82002ac346..45b23fcbb5 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -409,7 +409,7 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx)
}
avctx->extradata_size = header_size;
- opus->samples = av_mallocz_array(frame_size, avctx->channels *
+ opus->samples = av_calloc(frame_size, avctx->channels *
av_get_bytes_per_sample(avctx->sample_fmt));
if (!opus->samples) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate samples buffer.\n");
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index f66345e998..10e5a22fa9 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1492,7 +1492,7 @@ static int set_roi_map(AVCodecContext *avctx, const AVFrameSideData *sd, int fra
roi_map->rows = (frame_height + block_size - 1) / block_size;
roi_map->cols = (frame_width + block_size - 1) / block_size;
- roi_map->roi_map = av_mallocz_array(roi_map->rows * roi_map->cols, sizeof(*roi_map->roi_map));
+ roi_map->roi_map = av_calloc(roi_map->rows * roi_map->cols, sizeof(*roi_map->roi_map));
if (!roi_map->roi_map) {
av_log(avctx, AV_LOG_ERROR, "roi_map alloc failed.\n");
return AVERROR(ENOMEM);
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 379c167e6f..0f886713e3 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -397,7 +397,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
}
nb_rois = sd->size / roi_size;
- qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
+ qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
if (!qoffsets)
return AVERROR(ENOMEM);
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 839b6ce9de..7dd70a3450 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -460,7 +460,7 @@ static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
}
nb_rois = sd->size / roi_size;
- qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
+ qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
if (!qoffsets)
return AVERROR(ENOMEM);
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 15bb8e5c1c..20b3b0f804 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -347,7 +347,7 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
if (!x4->enc)
return AVERROR_EXTERNAL;
- if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer))))
+ if (!FF_ALLOCZ_TYPED_ARRAY(x4->pts_buffer, avctx->max_b_frames + 1))
return AVERROR(ENOMEM);
/* TAG: Do we have GLOBAL HEADER in AVS */
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 2a5868fe1d..69f6b08ed6 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -761,8 +761,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
- s->blocks[i] = av_mallocz_array(size, sizeof(**s->blocks));
- s->last_nnz[i] = av_mallocz_array(size, sizeof(**s->last_nnz));
+ s->blocks[i] = av_calloc(size, sizeof(**s->blocks));
+ s->last_nnz[i] = av_calloc(size, sizeof(**s->last_nnz));
if (!s->blocks[i] || !s->last_nnz[i])
return AVERROR(ENOMEM);
s->block_stride[i] = bw * s->h_count[i];
diff --git a/libavcodec/mlz.c b/libavcodec/mlz.c
index ebce796ba5..dbeb7dcad9 100644
--- a/libavcodec/mlz.c
+++ b/libavcodec/mlz.c
@@ -21,7 +21,7 @@
#include "mlz.h"
av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {
- mlz->dict = av_mallocz_array(TABLE_SIZE, sizeof(*mlz->dict));
+ mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict));
mlz->flush_code = FLUSH_CODE;
mlz->current_dic_index_max = DIC_INDEX_INIT;
diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 1896330fe1..7ac9634538 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -80,10 +80,10 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
mp->avctx = avctx;
ff_bswapdsp_init(&mp->bdsp);
- mp->changes_map = av_mallocz_array(avctx->width, h4);
+ mp->changes_map = av_calloc(avctx->width, h4);
mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
- mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel));
- mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel));
+ mp->vpt = av_calloc(avctx->height, sizeof(*mp->vpt));
+ mp->hpt = av_calloc(h4 / 4, w4 / 4 * sizeof(*mp->hpt));
if (!mp->changes_map || !mp->vpt || !mp->hpt)
return AVERROR(ENOMEM);
avctx->pix_fmt = AV_PIX_FMT_RGB555;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ae25afd7f8..edc46ed33a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1578,7 +1578,7 @@ static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
NvencContext *ctx = avctx->priv_data;
int i, res = 0, res2;
- ctx->surfaces = av_mallocz_array(ctx->nb_surfaces, sizeof(*ctx->surfaces));
+ ctx->surfaces = av_calloc(ctx->nb_surfaces, sizeof(*ctx->surfaces));
if (!ctx->surfaces)
return AVERROR(ENOMEM);
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 4078ac84a4..cec0d04b8a 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -360,7 +360,7 @@ static av_cold int find_component(OMXContext *omx_context, void *logctx,
av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role);
return AVERROR_ENCODER_NOT_FOUND;
}
- components = av_mallocz_array(num, sizeof(*components));
+ components = av_calloc(num, sizeof(*components));
if (!components)
return AVERROR(ENOMEM);
for (i = 0; i < num; i++) {
diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index 5ca6ca92f3..df8ba93fa9 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -400,7 +400,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
return AVERROR_PATCHWELCOME;
}
- s->channel_maps = av_mallocz_array(channels, sizeof(*s->channel_maps));
+ s->channel_maps = av_calloc(channels, sizeof(*s->channel_maps));
if (!s->channel_maps)
return AVERROR(ENOMEM);
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index 3ebf199219..b063e0efeb 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -634,7 +634,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
return ret;
/* allocate and init each independent decoder */
- c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));
+ c->streams = av_calloc(c->nb_streams, sizeof(*c->streams));
if (!c->streams) {
c->nb_streams = 0;
return AVERROR(ENOMEM);
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 55eda4c2a9..388639a110 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -518,7 +518,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
// Blank if last object_count was 0.
if (!ctx->presentation.object_count)
return 1;
- sub->rects = av_mallocz_array(ctx->presentation.object_count, sizeof(*sub->rects));
+ sub->rects = av_calloc(ctx->presentation.object_count, sizeof(*sub->rects));
if (!sub->rects) {
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/png.c b/libavcodec/png.c
index 4ea286075d..e772eaad26 100644
--- a/libavcodec/png.c
+++ b/libavcodec/png.c
@@ -40,7 +40,7 @@ static const uint8_t ff_png_pass_xshift[NB_PASSES] = {
void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
{
- return av_mallocz_array(items, size);
+ return av_calloc(items, size);
}
void ff_png_zfree(void *opaque, void *ptr)
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index fe1f3a28bd..7750620b22 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -340,7 +340,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
if (ctx->slice_count != slice_count || !ctx->slices) {
av_freep(&ctx->slices);
ctx->slice_count = 0;
- ctx->slices = av_mallocz_array(slice_count, sizeof(*ctx->slices));
+ ctx->slices = av_calloc(slice_count, sizeof(*ctx->slices));
if (!ctx->slices)
return AVERROR(ENOMEM);
ctx->slice_count = slice_count;
diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
index 2b5f111fbe..93c8408297 100644
--- a/libavcodec/psymodel.c
+++ b/libavcodec/psymodel.c
@@ -35,8 +35,8 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
int i, j, k = 0;
ctx->avctx = avctx;
- ctx->ch = av_mallocz_array(sizeof(ctx->ch[0]), avctx->channels * 2);
- ctx->group = av_mallocz_array(sizeof(ctx->group[0]), num_groups);
+ ctx->ch = av_calloc(avctx->channels, 2 * sizeof(ctx->ch[0]));
+ ctx->group = av_calloc(num_groups, sizeof(ctx->group[0]));
ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens);
ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens);
ctx->cutoff = avctx->cutoff;
@@ -120,7 +120,7 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
FF_FILTER_MODE_LOWPASS, FILT_ORDER,
cutoff_coeff, 0.0, 0.0);
if (ctx->fcoeffs) {
- ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels);
+ ctx->fstate = av_calloc(avctx->channels, sizeof(ctx->fstate[0]));
if (!ctx->fstate) {
av_free(ctx->fcoeffs);
av_free(ctx);
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 9c5d66c0d4..73b1b7d7d9 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -878,7 +878,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
if (codec->type == AVMEDIA_TYPE_VIDEO)
avctx->delay = src->thread_count - 1;
- fctx->threads = av_mallocz_array(thread_count, sizeof(PerThreadContext));
+ fctx->threads = av_calloc(thread_count, sizeof(*fctx->threads));
if (!fctx->threads) {
err = AVERROR(ENOMEM);
goto error;
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index 80c4579fc0..86411b21be 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -211,7 +211,7 @@ int ff_alloc_entries(AVCodecContext *avctx, int count)
}
p->thread_count = avctx->thread_count;
- p->entries = av_mallocz_array(count, sizeof(int));
+ p->entries = av_calloc(count, sizeof(*p->entries));
if (!p->progress_mutex) {
p->progress_mutex = av_malloc_array(p->thread_count, sizeof(pthread_mutex_t));
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 2f332092a1..9d08485c92 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -452,7 +452,7 @@ static AVBufferRef *qsv_create_mids(AVBufferRef *hw_frames_ref)
if (!hw_frames_ref1)
return NULL;
- mids = av_mallocz_array(nb_surfaces, sizeof(*mids));
+ mids = av_calloc(nb_surfaces, sizeof(*mids));
if (!mids) {
av_buffer_unref(&hw_frames_ref1);
return NULL;
@@ -487,7 +487,7 @@ static int qsv_setup_mids(mfxFrameAllocResponse *resp, AVBufferRef *hw_frames_re
// the allocated size of the array is two larger than the number of
// surfaces, we store the references to the frames context and the
// QSVMid array there
- resp->mids = av_mallocz_array(nb_surfaces + 2, sizeof(*resp->mids));
+ resp->mids = av_calloc(nb_surfaces + 2, sizeof(*resp->mids));
if (!resp->mids)
return AVERROR(ENOMEM);
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 090fdbe75e..f7bb3f5eff 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1181,8 +1181,8 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
AVQSVContext *qsv = avctx->hwaccel_context;
int i, j;
- q->extparam = av_mallocz_array(qsv->nb_ext_buffers + q->nb_extparam_internal,
- sizeof(*q->extparam));
+ q->extparam = av_calloc(qsv->nb_ext_buffers + q->nb_extparam_internal,
+ sizeof(*q->extparam));
if (!q->extparam)
return AVERROR(ENOMEM);
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 4089157d47..fd131995b3 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -111,7 +111,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
s->rlecode_table = av_mallocz(s->logical_width);
s->skip_table = av_mallocz(s->logical_width);
- s->length_table = av_mallocz_array(s->logical_width + 1, sizeof(int));
+ s->length_table = av_calloc(s->logical_width + 1, sizeof(*s->length_table));
if (!s->skip_table || !s->length_table || !s->rlecode_table) {
av_log(avctx, AV_LOG_ERROR, "Error allocating memory.\n");
return AVERROR(ENOMEM);
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index f8e363ada7..3eac96f25e 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -1003,13 +1003,13 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
enc->this_motion4 =
- av_mallocz_array(roq->width * roq->height / 16, sizeof(motion_vect));
+ av_calloc(roq->width * roq->height / 16, sizeof(*enc->this_motion4));
enc->last_motion4 =
av_malloc_array (roq->width * roq->height / 16, sizeof(motion_vect));
enc->this_motion8 =
- av_mallocz_array(roq->width * roq->height / 64, sizeof(motion_vect));
+ av_calloc(roq->width * roq->height / 64, sizeof(*enc->this_motion8));
enc->last_motion8 =
av_malloc_array (roq->width * roq->height / 64, sizeof(motion_vect));
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index a037e36873..e0fb58042c 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -116,7 +116,7 @@ int ff_snow_alloc_blocks(SnowContext *s){
s->b_height= h;
av_free(s->block);
- s->block= av_mallocz_array(w * h, sizeof(BlockNode) << (s->block_max_depth*2));
+ s->block = av_calloc(w * h, sizeof(*s->block) << (s->block_max_depth*2));
if (!s->block)
return AVERROR(ENOMEM);
@@ -567,7 +567,8 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
b->parent= &s->plane[plane_index].band[level-1][orientation];
//FIXME avoid this realloc
av_freep(&b->x_coeff);
- b->x_coeff=av_mallocz_array(((b->width+1) * b->height+1), sizeof(x_and_coeff));
+ b->x_coeff = av_calloc((b->width + 1) * b->height + 1,
+ sizeof(*b->x_coeff));
if (!b->x_coeff)
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c
index 3dca3c6d30..c093ebff07 100644
--- a/libavcodec/snow_dwt.c
+++ b/libavcodec/snow_dwt.c
@@ -35,7 +35,7 @@ int ff_slice_buffer_init(slice_buffer *buf, int line_count,
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
- buf->line = av_mallocz_array(line_count, sizeof(IDWTELEM *));
+ buf->line = av_calloc(line_count, sizeof(*buf->line));
if (!buf->line)
return AVERROR(ENOMEM);
buf->data_stack = av_malloc_array(max_allocated_lines, sizeof(IDWTELEM *));
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index d2c0beb1aa..55ebfba50f 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -79,7 +79,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->m.mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol
s->m.me.temp =
- s->m.me.scratchpad= av_mallocz_array((avctx->width+64), 2*16*2*sizeof(uint8_t));
+ s->m.me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.sc.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
@@ -145,8 +145,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
if(s->motion_est == FF_ME_ITER){
int size= s->b_width * s->b_height << 2*s->block_max_depth;
for(i=0; i<s->max_ref_frames; i++){
- s->ref_mvs[i]= av_mallocz_array(size, sizeof(int16_t[2]));
- s->ref_scores[i]= av_mallocz_array(size, sizeof(uint32_t));
+ s->ref_mvs[i] = av_calloc(size, sizeof(*s->ref_mvs[i]));
+ s->ref_scores[i] = av_calloc(size, sizeof(*s->ref_scores[i]));
if (!s->ref_mvs[i] || !s->ref_scores[i])
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index b2c8215002..e329578af0 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1364,7 +1364,7 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic)
goto fail;
if (!s->edge_emu_buffer) {
- s->edge_emu_buffer = av_mallocz_array(pic->f->linesize[0], 17);
+ s->edge_emu_buffer = av_calloc(pic->f->linesize[0], 17);
if (!s->edge_emu_buffer)
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/tests/snowenc.c b/libavcodec/tests/snowenc.c
index d5f94e8a61..07af1f2cf9 100644
--- a/libavcodec/tests/snowenc.c
+++ b/libavcodec/tests/snowenc.c
@@ -37,8 +37,8 @@ int main(void){
s.spatial_decomposition_count=6;
s.spatial_decomposition_type=1;
- s.temp_dwt_buffer = av_mallocz_array(width, sizeof(DWTELEM));
- s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
+ s.temp_dwt_buffer = av_calloc(width, sizeof(*s.temp_dwt_buffer));
+ s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_buffer));
if (!s.temp_dwt_buffer || !s.temp_idwt_buffer) {
fprintf(stderr, "Failed to allocate memory\n");
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 8566f7ba74..870e0666aa 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1588,7 +1588,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
s->geotag_count = 0;
return -1;
}
- s->geotags = av_mallocz_array(s->geotag_count, sizeof(TiffGeoTag));
+ s->geotags = av_calloc(s->geotag_count, sizeof(*s->geotags));
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
s->geotag_count = 0;
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index d9ff45fad6..17b4ca9032 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -107,7 +107,8 @@ static int allocate_buffers(AVCodecContext *avctx)
TTAContext *s = avctx->priv_data;
if (s->bps < 3) {
- s->decode_buffer = av_mallocz_array(sizeof(int32_t)*s->frame_length, s->channels);
+ s->decode_buffer = av_calloc(s->frame_length,
+ sizeof(*s->decode_buffer) * s->channels);
if (!s->decode_buffer)
return AVERROR(ENOMEM);
} else
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index cfc07cbcb8..387d285633 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -379,8 +379,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
planar = av_sample_fmt_is_planar(sample_fmt);
if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
- if (!(frame->extended_data = av_mallocz_array(nb_channels,
- sizeof(*frame->extended_data))))
+ if (!FF_ALLOCZ_TYPED_ARRAY(frame->extended_data, nb_channels))
return AVERROR(ENOMEM);
} else {
frame->extended_data = frame->data;
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 7510816ec1..ec054ae701 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -429,7 +429,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
if (pic->nb_slices == 0)
pic->nb_slices = ctx->nb_slices;
if (pic->nb_slices > 0) {
- pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices));
+ pic->slices = av_calloc(pic->nb_slices, sizeof(*pic->slices));
if (!pic->slices) {
err = AVERROR(ENOMEM);
goto fail;
@@ -511,7 +511,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
nb_roi = ctx->roi_max_regions;
}
- pic->roi = av_mallocz_array(nb_roi, sizeof(*pic->roi));
+ pic->roi = av_calloc(nb_roi, sizeof(*pic->roi));
if (!pic->roi) {
err = AVERROR(ENOMEM);
goto fail;
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index dac2b6841c..6e07bc5a8a 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -379,7 +379,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
// Weed out unused vlcs and build codevector vector
if (used_entries) {
codebook_setup->codevectors =
- av_mallocz_array(used_entries, codebook_setup->dimensions *
+ av_calloc(used_entries, codebook_setup->dimensions *
sizeof(*codebook_setup->codevectors));
if (!codebook_setup->codevectors) {
ret = AVERROR(ENOMEM);
@@ -567,7 +567,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
for (j = 0; j < floor_setup->data.t1.partitions; ++j)
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
- floor_setup->data.t1.list = av_mallocz_array(floor_setup->data.t1.x_list_dim,
+ floor_setup->data.t1.list = av_calloc(floor_setup->data.t1.x_list_dim,
sizeof(*floor_setup->data.t1.list));
if (!floor_setup->data.t1.list)
return AVERROR(ENOMEM);
@@ -823,7 +823,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
}
if (mapping_setup->submaps>1) {
- mapping_setup->mux = av_mallocz_array(vc->audio_channels,
+ mapping_setup->mux = av_calloc(vc->audio_channels,
sizeof(*mapping_setup->mux));
if (!mapping_setup->mux)
return AVERROR(ENOMEM);
@@ -1000,7 +1000,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
}
vc->channel_residues = av_malloc_array(vc->blocksize[1] / 2, vc->audio_channels * sizeof(*vc->channel_residues));
- vc->saved = av_mallocz_array(vc->blocksize[1] / 4, vc->audio_channels * sizeof(*vc->saved));
+ vc->saved = av_calloc(vc->blocksize[1] / 4, vc->audio_channels * sizeof(*vc->saved));
if (!vc->channel_residues || !vc->saved)
return AVERROR(ENOMEM);
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 72c6ba1130..858c6ac6dd 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -182,7 +182,7 @@ static int ready_codebook(vorbis_enc_codebook *cb)
} else {
int vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
cb->dimensions = av_malloc_array(cb->nentries, sizeof(float) * cb->ndimensions);
- cb->pow2 = av_mallocz_array(cb->nentries, sizeof(float));
+ cb->pow2 = av_calloc(cb->nentries, sizeof(*cb->pow2));
if (!cb->dimensions || !cb->pow2)
return AVERROR(ENOMEM);
for (i = 0; i < cb->nentries; i++) {
@@ -212,7 +212,7 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
{
int i;
av_assert0(rc->type == 2);
- rc->maxes = av_mallocz_array(rc->classifications, sizeof(float[2]));
+ rc->maxes = av_calloc(rc->classifications, sizeof(*rc->maxes));
if (!rc->maxes)
return AVERROR(ENOMEM);
for (i = 0; i < rc->classifications; i++) {
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 166c1bf60d..16726080b3 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2277,19 +2277,19 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
/* superblock_coding is used by unpack_superblocks (VP3/Theora) and vp4_unpack_macroblocks (VP4) */
s->superblock_coding = av_mallocz(FFMAX(s->superblock_count, s->yuv_macroblock_count));
- s->all_fragments = av_mallocz_array(s->fragment_count, sizeof(Vp3Fragment));
+ s->all_fragments = av_calloc(s->fragment_count, sizeof(*s->all_fragments));
- s-> kf_coded_fragment_list = av_mallocz_array(s->fragment_count, sizeof(int));
- s->nkf_coded_fragment_list = av_mallocz_array(s->fragment_count, sizeof(int));
+ s-> kf_coded_fragment_list = av_calloc(s->fragment_count, sizeof(int));
+ s->nkf_coded_fragment_list = av_calloc(s->fragment_count, sizeof(int));
memset(s-> num_kf_coded_fragment, -1, sizeof(s-> num_kf_coded_fragment));
- s->dct_tokens_base = av_mallocz_array(s->fragment_count,
- 64 * sizeof(*s->dct_tokens_base));
- s->motion_val[0] = av_mallocz_array(y_fragment_count, sizeof(*s->motion_val[0]));
- s->motion_val[1] = av_mallocz_array(c_fragment_count, sizeof(*s->motion_val[1]));
+ s->dct_tokens_base = av_calloc(s->fragment_count,
+ 64 * sizeof(*s->dct_tokens_base));
+ s->motion_val[0] = av_calloc(y_fragment_count, sizeof(*s->motion_val[0]));
+ s->motion_val[1] = av_calloc(c_fragment_count, sizeof(*s->motion_val[1]));
/* work out the block mapping tables */
- s->superblock_fragments = av_mallocz_array(s->superblock_count, 16 * sizeof(int));
+ s->superblock_fragments = av_calloc(s->superblock_count, 16 * sizeof(int));
s->macroblock_coding = av_mallocz(s->macroblock_count + 1);
s->dc_pred_row = av_malloc_array(s->y_superblock_width * 4, sizeof(*s->dc_pred_row));
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index c1b58d4752..8317ac6bd8 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -793,7 +793,7 @@ static int decode_frame_header(AVCodecContext *avctx,
} else {
n_range_coders = s->s.h.tiling.tile_cols;
}
- s->td = av_mallocz_array(s->active_tile_cols, sizeof(VP9TileData) +
+ s->td = av_calloc(s->active_tile_cols, sizeof(VP9TileData) +
n_range_coders * sizeof(VP56RangeCoder));
if (!s->td)
return AVERROR(ENOMEM);
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 3efd4438d9..8b19ba4e64 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -581,8 +581,8 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
img->color_cache_bits);
return AVERROR_INVALIDDATA;
}
- img->color_cache = av_mallocz_array(1 << img->color_cache_bits,
- sizeof(*img->color_cache));
+ img->color_cache = av_calloc(1 << img->color_cache_bits,
+ sizeof(*img->color_cache));
if (!img->color_cache)
return AVERROR(ENOMEM);
} else {
@@ -596,9 +596,9 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
return ret;
img->nb_huffman_groups = s->nb_huffman_groups;
}
- img->huffman_groups = av_mallocz_array(img->nb_huffman_groups *
- HUFFMAN_CODES_PER_META_CODE,
- sizeof(*img->huffman_groups));
+ img->huffman_groups = av_calloc(img->nb_huffman_groups,
+ HUFFMAN_CODES_PER_META_CODE *
+ sizeof(*img->huffman_groups));
if (!img->huffman_groups)
return AVERROR(ENOMEM);
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 41212d922a..92557713c4 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -257,7 +257,7 @@ static int config_output(AVFilterLink *outlink)
if (!s->frame_list)
return AVERROR(ENOMEM);
- s->fifos = av_mallocz_array(s->nb_inputs, sizeof(*s->fifos));
+ s->fifos = av_calloc(s->nb_inputs, sizeof(*s->fifos));
if (!s->fifos)
return AVERROR(ENOMEM);
@@ -274,8 +274,8 @@ static int config_output(AVFilterLink *outlink)
memset(s->input_state, INPUT_ON, s->nb_inputs);
s->active_inputs = s->nb_inputs;
- s->input_scale = av_mallocz_array(s->nb_inputs, sizeof(*s->input_scale));
- s->scale_norm = av_mallocz_array(s->nb_inputs, sizeof(*s->scale_norm));
+ s->input_scale = av_calloc(s->nb_inputs, sizeof(*s->input_scale));
+ s->scale_norm = av_calloc(s->nb_inputs, sizeof(*s->scale_norm));
if (!s->input_scale || !s->scale_norm)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_inputs; i++)
@@ -561,7 +561,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!s->fdsp)
return AVERROR(ENOMEM);
- s->weights = av_mallocz_array(s->nb_inputs, sizeof(*s->weights));
+ s->weights = av_calloc(s->nb_inputs, sizeof(*s->weights));
if (!s->weights)
return AVERROR(ENOMEM);
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index c1eac79c98..f5a57539fe 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -310,7 +310,7 @@ static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
if (nch_out > nch_in) {
if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
uint8_t **new_extended_data =
- av_mallocz_array(nch_out, sizeof(*buf->extended_data));
+ av_calloc(nch_out, sizeof(*buf->extended_data));
if (!new_extended_data) {
av_frame_free(&buf);
return AVERROR(ENOMEM);
diff --git a/libavfilter/af_compand.c b/libavfilter/af_compand.c
index 1df28d5590..0172b5f876 100644
--- a/libavfilter/af_compand.c
+++ b/libavfilter/af_compand.c
@@ -344,9 +344,9 @@ static int config_output(AVFilterLink *outlink)
uninit(ctx);
- s->channels = av_mallocz_array(channels, sizeof(*s->channels));
+ s->channels = av_calloc(channels, sizeof(*s->channels));
s->nb_segments = (nb_points + 4) * 2;
- s->segments = av_mallocz_array(s->nb_segments, sizeof(*s->segments));
+ s->segments = av_calloc(s->nb_segments, sizeof(*s->segments));
if (!s->channels || !s->segments) {
uninit(ctx);
diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index c8e58260da..2fe1fc9429 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -172,9 +172,9 @@ static av_cold int join_init(AVFilterContext *ctx)
}
s->nb_channels = av_get_channel_layout_nb_channels(s->channel_layout);
- s->channels = av_mallocz_array(s->nb_channels, sizeof(*s->channels));
- s->buffers = av_mallocz_array(s->nb_channels, sizeof(*s->buffers));
- s->input_frames = av_mallocz_array(s->inputs, sizeof(*s->input_frames));
+ s->channels = av_calloc(s->nb_channels, sizeof(*s->channels));
+ s->buffers = av_calloc(s->nb_channels, sizeof(*s->buffers));
+ s->input_frames = av_calloc(s->inputs, sizeof(*s->input_frames));
if (!s->channels || !s->buffers|| !s->input_frames)
return AVERROR(ENOMEM);
@@ -283,7 +283,7 @@ static int join_config_output(AVFilterLink *outlink)
int i, ret = 0;
/* initialize inputs to user-specified mappings */
- if (!(inputs = av_mallocz_array(ctx->nb_inputs, sizeof(*inputs))))
+ if (!(inputs = av_calloc(ctx->nb_inputs, sizeof(*inputs))))
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_channels; i++) {
ChannelMap *ch = &s->channels[i];
@@ -383,7 +383,7 @@ static int try_push_frame(AVFilterContext *ctx)
if (!frame)
return AVERROR(ENOMEM);
if (s->nb_channels > FF_ARRAY_ELEMS(frame->data)) {
- frame->extended_data = av_mallocz_array(s->nb_channels,
+ frame->extended_data = av_calloc(s->nb_channels,
sizeof(*frame->extended_data));
if (!frame->extended_data) {
ret = AVERROR(ENOMEM);
@@ -417,8 +417,8 @@ static int try_push_frame(AVFilterContext *ctx)
/* create references to the buffers we copied to output */
if (nb_buffers > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = nb_buffers - FF_ARRAY_ELEMS(frame->buf);
- frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
- sizeof(*frame->extended_buf));
+ frame->extended_buf = av_calloc(frame->nb_extended_buf,
+ sizeof(*frame->extended_buf));
if (!frame->extended_buf) {
frame->nb_extended_buf = 0;
ret = AVERROR(ENOMEM);
diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 93ec5f7171..eb38d2811c 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -169,7 +169,8 @@ static int config_input(AVFilterLink *inlink)
s->channels = inlink->channels;
s->duration = av_rescale(s->duration, inlink->sample_rate, AV_TIME_BASE);
s->independent_channels = s->mono ? s->channels : 1;
- s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independent_channels);
+ s->nb_null_samples = av_calloc(s->independent_channels,
+ sizeof(*s->nb_null_samples));
if (!s->nb_null_samples)
return AVERROR(ENOMEM);
s->start = av_malloc_array(sizeof(*s->start), s->independent_channels);
diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
index e75ed88729..90180309dd 100644
--- a/libavfilter/avf_showwaves.c
+++ b/libavfilter/avf_showwaves.c
@@ -427,7 +427,7 @@ static int config_output(AVFilterLink *outlink)
showwaves->n = FFMAX(1, av_rescale_q(inlink->sample_rate, av_make_q(1, showwaves->w), showwaves->rate));
showwaves->buf_idx = 0;
- if (!(showwaves->buf_idy = av_mallocz_array(nb_channels, sizeof(*showwaves->buf_idy)))) {
+ if (!FF_ALLOCZ_TYPED_ARRAY(showwaves->buf_idy, nb_channels)) {
av_log(ctx, AV_LOG_ERROR, "Could not allocate showwaves buffer\n");
return AVERROR(ENOMEM);
}
@@ -820,7 +820,7 @@ static int showwavespic_config_input(AVFilterLink *inlink)
ShowWavesContext *showwaves = ctx->priv;
if (showwaves->single_pic) {
- showwaves->sum = av_mallocz_array(inlink->channels, sizeof(*showwaves->sum));
+ showwaves->sum = av_calloc(inlink->channels, sizeof(*showwaves->sum));
if (!showwaves->sum)
return AVERROR(ENOMEM);
}
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c614eb0740..6916dbb24c 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -702,7 +702,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
ret->input_pads = av_memdup(filter->inputs, ret->nb_inputs * sizeof(*filter->inputs));
if (!ret->input_pads)
goto err;
- ret->inputs = av_mallocz_array(ret->nb_inputs, sizeof(AVFilterLink*));
+ ret->inputs = av_calloc(ret->nb_inputs, sizeof(*ret->inputs));
if (!ret->inputs)
goto err;
}
@@ -712,7 +712,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
ret->output_pads = av_memdup(filter->outputs, ret->nb_outputs * sizeof(*filter->outputs));
if (!ret->output_pads)
goto err;
- ret->outputs = av_mallocz_array(ret->nb_outputs, sizeof(AVFilterLink*));
+ ret->outputs = av_calloc(ret->nb_outputs, sizeof(*ret->outputs));
if (!ret->outputs)
goto err;
}
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index c95cad7944..7dd48fb612 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -1006,7 +1006,7 @@ static DNNReturnType fill_model_input_tf(TFModel *tf_model, TFRequestItem *reque
goto err;
}
- infer_request->output_tensors = av_mallocz_array(task->nb_output, sizeof(*infer_request->output_tensors));
+ infer_request->output_tensors = av_calloc(task->nb_output, sizeof(*infer_request->output_tensors));
if (!infer_request->output_tensors) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output tensor\n");
goto err;
diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
index 3045ce0131..3c7a962b3a 100644
--- a/libavfilter/dnn_filter_common.c
+++ b/libavfilter/dnn_filter_common.c
@@ -29,7 +29,7 @@ static char **separate_output_names(const char *expr, const char *val_sep, int *
return NULL;
}
- parsed_vals = av_mallocz_array(MAX_SUPPORTED_OUTPUTS_NB, sizeof(*parsed_vals));
+ parsed_vals = av_calloc(MAX_SUPPORTED_OUTPUTS_NB, sizeof(*parsed_vals));
if (!parsed_vals) {
return NULL;
}
diff --git a/libavfilter/ebur128.c b/libavfilter/ebur128.c
index d93500ef3e..1a85a90360 100644
--- a/libavfilter/ebur128.c
+++ b/libavfilter/ebur128.c
@@ -232,7 +232,7 @@ FFEBUR128State *ff_ebur128_init(unsigned int channels,
CHECK_ERROR(errcode, 0, free_internal)
st->d->sample_peak =
- (double *) av_mallocz_array(channels, sizeof(*st->d->sample_peak));
+ (double *) av_calloc(channels, sizeof(*st->d->sample_peak));
CHECK_ERROR(!st->d->sample_peak, 0, free_channel_map)
st->samplerate = samplerate;
@@ -253,8 +253,8 @@ FFEBUR128State *ff_ebur128_init(unsigned int channels,
- (st->d->audio_data_frames % st->d->samples_in_100ms);
}
st->d->audio_data =
- (double *) av_mallocz_array(st->d->audio_data_frames,
- st->channels * sizeof(*st->d->audio_data));
+ (double *) av_calloc(st->d->audio_data_frames,
+ st->channels * sizeof(*st->d->audio_data));
CHECK_ERROR(!st->d->audio_data, 0, free_sample_peak)
ebur128_init_filter(st);
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 9123403c40..7c63807df3 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -243,11 +243,11 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
frame->linesize[0] = pool->linesize[0];
if (pool->planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz_array(pool->planes,
- sizeof(*frame->extended_data));
+ frame->extended_data = av_calloc(pool->planes,
+ sizeof(*frame->extended_data));
frame->nb_extended_buf = pool->planes - AV_NUM_DATA_POINTERS;
- frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
- sizeof(*frame->extended_buf));
+ frame->extended_buf = av_calloc(frame->nb_extended_buf,
+ sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf)
goto fail;
} else {
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 135d4c4e36..d1218355c7 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -499,8 +499,8 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
s->in_mem_mode = in_frames_hwctx->frame_type;
- s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs_in));
+ s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs_in));
if (!s->surface_ptrs_in)
return AVERROR(ENOMEM);
@@ -548,8 +548,8 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
return ret;
}
- s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs_out));
+ s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs_out));
if (!s->surface_ptrs_out) {
av_buffer_unref(&out_frames_ref);
return AVERROR(ENOMEM);
@@ -672,7 +672,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p
if (ret < 0)
goto failed;
- s->frame_infos = av_mallocz_array(avctx->nb_inputs, sizeof(*s->frame_infos));
+ s->frame_infos = av_calloc(avctx->nb_inputs, sizeof(*s->frame_infos));
if (!s->frame_infos) {
ret = AVERROR(ENOMEM);
goto failed;
@@ -708,7 +708,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p
if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
s->nb_ext_buffers = param->num_ext_buf + 1;
- s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, sizeof(*s->ext_buffers));
+ s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
if (!s->ext_buffers) {
ret = AVERROR(ENOMEM);
goto failed;
diff --git a/libavfilter/tests/integral.c b/libavfilter/tests/integral.c
index 03b1e77367..6bdf0fd7fa 100644
--- a/libavfilter/tests/integral.c
+++ b/libavfilter/tests/integral.c
@@ -54,8 +54,8 @@ int main(void)
const int ii_lz_32 = ((ii_w + 1) + 3) & ~3;
// "+1" is for the space of the top 0-line
- uint32_t *ii = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii));
- uint32_t *ii2 = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii2));
+ uint32_t *ii = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii));
+ uint32_t *ii2 = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii2));
if (!ii || !ii2)
return -1;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index 25a17788c3..8c54f7c238 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -116,7 +116,7 @@ static int set_gauss(AVFilterContext *ctx)
int i;
for (i = 0; i <= difford; ++i) {
- s->gauss[i] = av_mallocz_array(filtersize, sizeof(*s->gauss[i]));
+ s->gauss[i] = av_calloc(filtersize, sizeof(*s->gauss[i]));
if (!s->gauss[i]) {
for (; i >= 0; --i) {
av_freep(&s->gauss[i]);
@@ -219,7 +219,8 @@ static int setup_derivative_buffers(AVFilterContext* ctx, ThreadData *td)
av_log(ctx, AV_LOG_TRACE, "Allocating %d buffer(s) for grey edge.\n", nb_buff);
for (b = 0; b <= nb_buff; ++b) { // We need difford + 1 buffers
for (p = 0; p < NUM_PLANES; ++p) {
- td->data[b][p] = av_mallocz_array(s->planeheight[p] * s->planewidth[p], sizeof(*td->data[b][p]));
+ td->data[b][p] = av_calloc(s->planeheight[p] * s->planewidth[p],
+ sizeof(*td->data[b][p]));
if (!td->data[b][p]) {
cleanup_derivative_buffers(td, b + 1, p);
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index 5642d0cd28..028cda8291 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -494,7 +494,7 @@ static av_cold int init(AVFilterContext *fctx)
av_log(ctx, AV_LOG_DEBUG, "Filter count: %i\n", ctx->num_filters);
// allocate CIFilter array
- ctx->filters = av_mallocz_array(ctx->num_filters, sizeof(CIFilter*));
+ ctx->filters = av_calloc(ctx->num_filters, sizeof(CIFilter*));
if (!ctx->filters) {
av_log(ctx, AV_LOG_ERROR, "Could not allocate filter array.\n");
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
index 570e8bded2..7d7773419e 100644
--- a/libavfilter/vf_curves.c
+++ b/libavfilter/vf_curves.c
@@ -666,7 +666,7 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < NB_COMP + 1; i++) {
if (!curves->graph[i])
- curves->graph[i] = av_mallocz_array(curves->lut_size, sizeof(*curves->graph[0]));
+ curves->graph[i] = av_calloc(curves->lut_size, sizeof(*curves->graph[0]));
if (!curves->graph[i])
return AVERROR(ENOMEM);
ret = parse_points_str(ctx, comp_points + i, curves->comp_points_str[i], curves->lut_size);
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 18b9a17760..173c314bb8 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -233,8 +233,8 @@ static int init_out_session(AVFilterContext *ctx)
s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;
if (opaque) {
- s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs));
+ s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs));
if (!s->surface_ptrs)
return AVERROR(ENOMEM);
for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
@@ -263,8 +263,8 @@ static int init_out_session(AVFilterContext *ctx)
.Free = frame_free,
};
- s->mem_ids = av_mallocz_array(hw_frames_hwctx->nb_surfaces,
- sizeof(*s->mem_ids));
+ s->mem_ids = av_calloc(hw_frames_hwctx->nb_surfaces,
+ sizeof(*s->mem_ids));
if (!s->mem_ids)
return AVERROR(ENOMEM);
for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
diff --git a/libavfilter/vf_dejudder.c b/libavfilter/vf_dejudder.c
index 0aa8ab7a1e..d74cd7b159 100644
--- a/libavfilter/vf_dejudder.c
+++ b/libavfilter/vf_dejudder.c
@@ -95,7 +95,7 @@ static av_cold int dejudder_init(AVFilterContext *ctx)
{
DejudderContext *s = ctx->priv;
- s->ringbuff = av_mallocz_array(s->cycle+2, sizeof(*s->ringbuff));
+ s->ringbuff = av_calloc(s->cycle + 2, sizeof(*s->ringbuff));
if (!s->ringbuff)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 4a5bc06871..f886395ab7 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -172,7 +172,7 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
ret = AVERROR_INVALIDDATA;
goto end;
}
- if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols))) {
+ if (!(*values = av_calloc(sizeof(int) * *rows, *cols))) {
ret = AVERROR(ENOMEM);
goto end;
}
diff --git a/libavfilter/vf_mestimate.c b/libavfilter/vf_mestimate.c
index 582da48568..578c3be812 100644
--- a/libavfilter/vf_mestimate.c
+++ b/libavfilter/vf_mestimate.c
@@ -100,7 +100,7 @@ static int config_input(AVFilterLink *inlink)
return AVERROR(EINVAL);
for (i = 0; i < 3; i++) {
- s->mv_table[i] = av_mallocz_array(s->b_count, sizeof(*s->mv_table[0]));
+ s->mv_table[i] = av_calloc(s->b_count, sizeof(*s->mv_table[0]));
if (!s->mv_table[i])
return AVERROR(ENOMEM);
}
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 33a4059042..f4e791a19e 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -353,7 +353,7 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < NB_FRAMES; i++) {
Frame *frame = &mi_ctx->frames[i];
- frame->blocks = av_mallocz_array(mi_ctx->b_count, sizeof(Block));
+ frame->blocks = av_calloc(mi_ctx->b_count, sizeof(*frame->blocks));
if (!frame->blocks)
return AVERROR(ENOMEM);
}
@@ -373,19 +373,19 @@ static int config_input(AVFilterLink *inlink)
else if (mi_ctx->me_mode == ME_MODE_BILAT)
me_ctx->get_cost = &get_sbad_ob;
- mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS));
- mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights));
- mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs));
+ mi_ctx->pixel_mvs = av_calloc(width * height, sizeof(*mi_ctx->pixel_mvs));
+ mi_ctx->pixel_weights = av_calloc(width * height, sizeof(*mi_ctx->pixel_weights));
+ mi_ctx->pixel_refs = av_calloc(width * height, sizeof(*mi_ctx->pixel_refs));
if (!mi_ctx->pixel_mvs || !mi_ctx->pixel_weights || !mi_ctx->pixel_refs)
return AVERROR(ENOMEM);
if (mi_ctx->me_mode == ME_MODE_BILAT)
- if (!(mi_ctx->int_blocks = av_mallocz_array(mi_ctx->b_count, sizeof(Block))))
+ if (!FF_ALLOCZ_TYPED_ARRAY(mi_ctx->int_blocks, mi_ctx->b_count))
return AVERROR(ENOMEM);
if (mi_ctx->me_method == AV_ME_METHOD_EPZS) {
for (i = 0; i < 3; i++) {
- mi_ctx->mv_table[i] = av_mallocz_array(mi_ctx->b_count, sizeof(*mi_ctx->mv_table[0]));
+ mi_ctx->mv_table[i] = av_calloc(mi_ctx->b_count, sizeof(*mi_ctx->mv_table[0]));
if (!mi_ctx->mv_table[i])
return AVERROR(ENOMEM);
}
@@ -601,7 +601,7 @@ static int var_size_bme(MIContext *mi_ctx, Block *block, int x_mb, int y_mb, int
}
if (!block->subs) {
- block->subs = av_mallocz_array(4, sizeof(Block));
+ block->subs = av_mallocz(4 * sizeof(*block->subs));
if (!block->subs)
return AVERROR(ENOMEM);
}
diff --git a/libavfilter/vf_nlmeans.c b/libavfilter/vf_nlmeans.c
index 39ed37368a..20107022c4 100644
--- a/libavfilter/vf_nlmeans.c
+++ b/libavfilter/vf_nlmeans.c
@@ -312,7 +312,7 @@ static int config_input(AVFilterLink *inlink)
s->ii_lz_32 = FFALIGN(s->ii_w + 1, 4);
// "+1" is for the space of the top 0-line
- s->ii_orig = av_mallocz_array(s->ii_h + 1, s->ii_lz_32 * sizeof(*s->ii_orig));
+ s->ii_orig = av_calloc(s->ii_h + 1, s->ii_lz_32 * sizeof(*s->ii_orig));
if (!s->ii_orig)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 578ef47e88..76bad4a984 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -325,8 +325,8 @@ static int overlay_qsv_init(AVFilterContext *ctx)
vpp->comp_conf.Header.BufferId = MFX_EXTBUFF_VPP_COMPOSITE;
vpp->comp_conf.Header.BufferSz = sizeof(vpp->comp_conf);
vpp->comp_conf.NumInputStream = ctx->nb_inputs;
- vpp->comp_conf.InputStream = av_mallocz_array(ctx->nb_inputs,
- sizeof(*vpp->comp_conf.InputStream));
+ vpp->comp_conf.InputStream = av_calloc(ctx->nb_inputs,
+ sizeof(*vpp->comp_conf.InputStream));
if (!vpp->comp_conf.InputStream)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c
index fdc6b4dcd1..1ffb18bde1 100644
--- a/libavfilter/vf_program_opencl.c
+++ b/libavfilter/vf_program_opencl.c
@@ -271,8 +271,7 @@ static av_cold int program_opencl_init(AVFilterContext *avctx)
} else {
int i;
- ctx->frames = av_mallocz_array(ctx->nb_inputs,
- sizeof(*ctx->frames));
+ ctx->frames = av_calloc(ctx->nb_inputs, sizeof(*ctx->frames));
if (!ctx->frames)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 2ab04457a9..5a37cef63d 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -343,16 +343,16 @@ static int init_out_session(AVFilterContext *ctx)
memset(&par, 0, sizeof(par));
if (opaque) {
- s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs_in));
+ s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs_in));
if (!s->surface_ptrs_in)
return AVERROR(ENOMEM);
for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i;
s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces;
- s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs_out));
+ s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs_out));
if (!s->surface_ptrs_out)
return AVERROR(ENOMEM);
for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
@@ -383,16 +383,16 @@ static int init_out_session(AVFilterContext *ctx)
.Free = frame_free,
};
- s->mem_ids_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
- sizeof(*s->mem_ids_in));
+ s->mem_ids_in = av_calloc(in_frames_hwctx->nb_surfaces,
+ sizeof(*s->mem_ids_in));
if (!s->mem_ids_in)
return AVERROR(ENOMEM);
for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId;
s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces;
- s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
- sizeof(*s->mem_ids_out));
+ s->mem_ids_out = av_calloc(out_frames_hwctx->nb_surfaces,
+ sizeof(*s->mem_ids_out));
if (!s->mem_ids_out)
return AVERROR(ENOMEM);
for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 41e35ac6ee..61a84ff990 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -478,7 +478,7 @@ static int config_input_ref(AVFilterLink *inlink)
return AVERROR(ENOMEM);
for (int t = 0; t < s->nb_threads; t++) {
- s->temp[t] = av_mallocz_array(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
+ s->temp[t] = av_calloc(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
if (!s->temp[t])
return AVERROR(ENOMEM);
}
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 98399b804a..b413133e41 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -229,7 +229,7 @@ static int init_filter_param(AVFilterContext *ctx, UnsharpFilterParam *fp, const
effect, effect_type, fp->msize_x, fp->msize_y, fp->amount / 65535.0);
fp->sr = av_malloc_array((MAX_MATRIX_SIZE - 1) * s->nb_threads, sizeof(uint32_t));
- fp->sc = av_mallocz_array(2 * fp->steps_y * s->nb_threads, sizeof(uint32_t *));
+ fp->sc = av_calloc(fp->steps_y * s->nb_threads, 2 * sizeof(*fp->sc));
if (!fp->sr || !fp->sc)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_yaepblur.c b/libavfilter/vf_yaepblur.c
index 983a2fec4f..c4e4a1f82d 100644
--- a/libavfilter/vf_yaepblur.c
+++ b/libavfilter/vf_yaepblur.c
@@ -294,11 +294,11 @@ static int config_input(AVFilterLink *inlink)
// padding one row on the top, and padding one col on the left, that is why + 1 below
s->sat_linesize = inlink->w + 1;
- s->sat = av_mallocz_array(inlink->h + 1, s->sat_linesize*sizeof(*s->sat));
+ s->sat = av_calloc(inlink->h + 1, s->sat_linesize * sizeof(*s->sat));
if (!s->sat)
return AVERROR(ENOMEM);
- s->square_sat = av_mallocz_array(inlink->h + 1, s->sat_linesize*sizeof(*s->square_sat));
+ s->square_sat = av_calloc(inlink->h + 1, s->sat_linesize * sizeof(*s->square_sat));
if (!s->square_sat)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vsrc_cellauto.c b/libavfilter/vsrc_cellauto.c
index 9a62cfedc3..b22e8be836 100644
--- a/libavfilter/vsrc_cellauto.c
+++ b/libavfilter/vsrc_cellauto.c
@@ -123,7 +123,7 @@ static int init_pattern_from_string(AVFilterContext *ctx)
s->h = (double)s->w * M_PHI;
}
- s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h);
+ s->buf = av_calloc(s->w, s->h * sizeof(*s->buf));
if (!s->buf)
return AVERROR(ENOMEM);
@@ -183,7 +183,7 @@ static av_cold int init(AVFilterContext *ctx)
/* fill the first row randomly */
int i;
- s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h);
+ s->buf = av_calloc(s->w, s->h * sizeof(*s->buf));
if (!s->buf)
return AVERROR(ENOMEM);
if (s->random_seed == -1)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index b1dea1362e..c4fac5eab2 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1665,7 +1665,7 @@ static int check_stream_max_drift(AVFormatContext *s)
{
int64_t min_pos, pos;
int i;
- int *idx = av_mallocz_array(s->nb_streams, sizeof(*idx));
+ int *idx = av_calloc(s->nb_streams, sizeof(*idx));
if (!idx)
return AVERROR(ENOMEM);
for (min_pos = pos = 0; min_pos != INT64_MAX; pos = min_pos + 1LU) {
diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index a3b4a2e11e..622491d2e5 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -84,7 +84,7 @@ static int hash_init(struct AVFormatContext *s)
int res;
struct HashContext *c = s->priv_data;
c->per_stream = 0;
- c->hashes = av_mallocz_array(1, sizeof(*c->hashes));
+ c->hashes = av_mallocz(sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
res = av_hash_alloc(&c->hashes[0], c->hash_name);
@@ -101,7 +101,7 @@ static int streamhash_init(struct AVFormatContext *s)
int res, i;
struct HashContext *c = s->priv_data;
c->per_stream = 1;
- c->hashes = av_mallocz_array(s->nb_streams, sizeof(*c->hashes));
+ c->hashes = av_calloc(s->nb_streams, sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
@@ -254,7 +254,7 @@ static int framehash_init(struct AVFormatContext *s)
int res;
struct HashContext *c = s->priv_data;
c->per_stream = 0;
- c->hashes = av_mallocz_array(1, sizeof(*c->hashes));
+ c->hashes = av_mallocz(sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
res = av_hash_alloc(&c->hashes[0], c->hash_name);
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 1793fb69d5..12365ad21f 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -326,7 +326,7 @@ static int hds_write_header(AVFormatContext *s)
return AVERROR_MUXER_NOT_FOUND;
}
- c->streams = av_mallocz_array(s->nb_streams, sizeof(*c->streams));
+ c->streams = av_calloc(s->nb_streams, sizeof(*c->streams));
if (!c->streams) {
return AVERROR(ENOMEM);
}
diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index a1ca15155f..ee793137fd 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -106,7 +106,7 @@ static int ico_write_header(AVFormatContext *s)
avio_skip(pb, 16);
}
- ico->images = av_mallocz_array(ico->nb_images, sizeof(IcoMuxContext));
+ ico->images = av_calloc(ico->nb_images, sizeof(*ico->images));
if (!ico->images)
return AVERROR(ENOMEM);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6e34243f6b..7899601bac 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2686,7 +2686,7 @@ static int mkv_init(struct AVFormatContext *s)
mkv->cur_audio_pkt = av_packet_alloc();
if (!mkv->cur_audio_pkt)
return AVERROR(ENOMEM);
- mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
+ mkv->tracks = av_calloc(s->nb_streams, sizeof(*mkv->tracks));
if (!mkv->tracks)
return AVERROR(ENOMEM);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4bc42d6b20..e484ada060 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2596,11 +2596,11 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
/* Prepare space for hosting multiple extradata. */
- sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata));
+ sc->extradata = av_calloc(entries, sizeof(*sc->extradata));
if (!sc->extradata)
return AVERROR(ENOMEM);
- sc->extradata_size = av_mallocz_array(entries, sizeof(*sc->extradata_size));
+ sc->extradata_size = av_calloc(entries, sizeof(*sc->extradata_size));
if (!sc->extradata_size) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -5998,7 +5998,7 @@ static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVSt
if (use_subsamples) {
subsample_count = avio_rb16(pb);
av_free((*sample)->subsamples);
- (*sample)->subsamples = av_mallocz_array(subsample_count, sizeof(*subsamples));
+ (*sample)->subsamples = av_calloc(subsample_count, sizeof(*subsamples));
if (!(*sample)->subsamples) {
av_encryption_info_free(*sample);
*sample = NULL;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d5929e6395..cfb5a5c725 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6670,7 +6670,7 @@ static int mov_init(AVFormatContext *s)
// Reserve an extra stream for chapters for the case where chapters
// are written in the trailer
- mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks));
+ mov->tracks = av_calloc(mov->nb_streams + 1, sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index ebe411b04d..876142d3a0 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1872,8 +1872,8 @@ static int mxf_compute_index_tables(MXFContext *mxf)
}
}
- mxf->index_tables = av_mallocz_array(mxf->nb_index_tables,
- sizeof(*mxf->index_tables));
+ mxf->index_tables = av_calloc(mxf->nb_index_tables,
+ sizeof(*mxf->index_tables));
if (!mxf->index_tables) {
av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
ret = AVERROR(ENOMEM);
@@ -1894,9 +1894,7 @@ static int mxf_compute_index_tables(MXFContext *mxf)
MXFIndexTable *t = &mxf->index_tables[j];
MXFTrack *mxf_track = NULL;
- t->segments = av_mallocz_array(t->nb_segments,
- sizeof(*t->segments));
-
+ t->segments = av_calloc(t->nb_segments, sizeof(*t->segments));
if (!t->segments) {
av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate IndexTableSegment"
" pointer array\n");
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7f08f151b6..b108aa6c7e 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -122,7 +122,7 @@ const URLProtocol **ffurl_get_protocols(const char *whitelist,
const URLProtocol **ret;
int i, ret_idx = 0;
- ret = av_mallocz_array(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
+ ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
if (!ret)
return NULL;
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 6e97c23330..0e91e3e315 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -748,7 +748,7 @@ static int rtsp_read_header(AVFormatContext *s)
return ret;
rt->real_setup_cache = !s->nb_streams ? NULL :
- av_mallocz_array(s->nb_streams, 2 * sizeof(*rt->real_setup_cache));
+ av_calloc(s->nb_streams, 2 * sizeof(*rt->real_setup_cache));
if (!rt->real_setup_cache && s->nb_streams) {
ret = AVERROR(ENOMEM);
goto fail;
diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c
index 1374a09906..9319ee6f80 100644
--- a/libavformat/sapenc.c
+++ b/libavformat/sapenc.c
@@ -133,7 +133,7 @@ static int sap_write_header(AVFormatContext *s)
freeaddrinfo(ai);
}
- contexts = av_mallocz_array(s->nb_streams, sizeof(AVFormatContext*));
+ contexts = av_calloc(s->nb_streams, sizeof(*contexts));
if (!contexts) {
ret = AVERROR(ENOMEM);
goto fail;
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 65ef942367..28ef2f4e80 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -295,7 +295,7 @@ static int ism_write_header(AVFormatContext *s)
return AVERROR_MUXER_NOT_FOUND;
}
- c->streams = av_mallocz_array(s->nb_streams, sizeof(*c->streams));
+ c->streams = av_calloc(s->nb_streams, sizeof(*c->streams));
if (!c->streams) {
return AVERROR(ENOMEM);
}
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 759535bdea..bb31218ac5 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -475,7 +475,7 @@ static int tee_write_header(AVFormatContext *avf)
filename++;
}
- if (!(tee->slaves = av_mallocz_array(nb_slaves, sizeof(*tee->slaves)))) {
+ if (!FF_ALLOCZ_TYPED_ARRAY(tee->slaves, nb_slaves)) {
ret = AVERROR(ENOMEM);
goto fail;
}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a322137fcf..8d998815ac 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4207,8 +4207,8 @@ int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
/* Copy side data if present */
if (src->nb_side_data) {
- dst->side_data = av_mallocz_array(src->nb_side_data,
- sizeof(AVPacketSideData));
+ dst->side_data = av_calloc(src->nb_side_data,
+ sizeof(*dst->side_data));
if (!dst->side_data)
return AVERROR(ENOMEM);
dst->nb_side_data = src->nb_side_data;
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 06e6047032..2317700be1 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -174,8 +174,8 @@ static av_cold int peak_init_writer(AVFormatContext *s)
return AVERROR(ERANGE);
wav->size_increment = par->channels * wav->peak_bps * wav->peak_ppv;
- wav->peak_maxpos = av_mallocz_array(par->channels, sizeof(*wav->peak_maxpos));
- wav->peak_maxneg = av_mallocz_array(par->channels, sizeof(*wav->peak_maxneg));
+ wav->peak_maxpos = av_calloc(par->channels, sizeof(*wav->peak_maxpos));
+ wav->peak_maxneg = av_calloc(par->channels, sizeof(*wav->peak_maxneg));
if (!wav->peak_maxpos || !wav->peak_maxneg)
goto nomem;
diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index fbe0f484e2..ec21a4f853 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -175,7 +175,7 @@ static int xmv_read_header(AVFormatContext *s)
avio_skip(pb, 2); /* Unknown (padding?) */
- xmv->audio = av_mallocz_array(xmv->audio_track_count, sizeof(XMVAudioPacket));
+ xmv->audio = av_calloc(xmv->audio_track_count, sizeof(*xmv->audio));
if (!xmv->audio)
return AVERROR(ENOMEM);
diff --git a/libavutil/audio_fifo.c b/libavutil/audio_fifo.c
index 1bf75ced54..243efc39e4 100644
--- a/libavutil/audio_fifo.c
+++ b/libavutil/audio_fifo.c
@@ -75,7 +75,7 @@ AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
af->sample_size = buf_size / nb_samples;
af->nb_buffers = av_sample_fmt_is_planar(sample_fmt) ? channels : 1;
- af->buf = av_mallocz_array(af->nb_buffers, sizeof(*af->buf));
+ af->buf = av_calloc(af->nb_buffers, sizeof(*af->buf));
if (!af->buf)
goto error;
diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
index dd3fa71a44..09486c4c85 100644
--- a/libavutil/encryption_info.c
+++ b/libavutil/encryption_info.c
@@ -48,7 +48,7 @@ AVEncryptionInfo *av_encryption_info_alloc(uint32_t subsample_count, uint32_t ke
info->key_id_size = key_id_size;
info->iv = av_mallocz(iv_size);
info->iv_size = iv_size;
- info->subsamples = av_mallocz_array(subsample_count, sizeof(*info->subsamples));
+ info->subsamples = av_calloc(subsample_count, sizeof(*info->subsamples));
info->subsample_count = subsample_count;
// Allow info->subsamples to be NULL if there are no subsamples.
@@ -185,7 +185,7 @@ AVEncryptionInitInfo *av_encryption_init_info_alloc(
info->system_id = av_mallocz(system_id_size);
info->system_id_size = system_id_size;
- info->key_ids = key_id_size ? av_mallocz_array(num_key_ids, sizeof(*info->key_ids)) : NULL;
+ info->key_ids = key_id_size ? av_calloc(num_key_ids, sizeof(*info->key_ids)) : NULL;
info->num_key_ids = num_key_ids;
info->key_id_size = key_id_size;
info->data = av_mallocz(data_size);
diff --git a/libavutil/frame.c b/libavutil/frame.c
index b0ceaf7145..2617cda2b5 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -210,9 +210,9 @@ static int get_audio_buffer(AVFrame *frame, int align)
}
if (planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz_array(planes,
+ frame->extended_data = av_calloc(planes,
sizeof(*frame->extended_data));
- frame->extended_buf = av_mallocz_array((planes - AV_NUM_DATA_POINTERS),
+ frame->extended_buf = av_calloc(planes - AV_NUM_DATA_POINTERS,
sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf) {
av_freep(&frame->extended_data);
@@ -367,8 +367,8 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
}
if (src->extended_buf) {
- dst->extended_buf = av_mallocz_array(sizeof(*dst->extended_buf),
- src->nb_extended_buf);
+ dst->extended_buf = av_calloc(src->nb_extended_buf,
+ sizeof(*dst->extended_buf));
if (!dst->extended_buf) {
ret = AVERROR(ENOMEM);
goto fail;
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index d13d0f7c9b..31c7840dba 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -308,7 +308,7 @@ static int hwframe_pool_prealloc(AVBufferRef *ref)
AVFrame **frames;
int i, ret = 0;
- frames = av_mallocz_array(ctx->initial_pool_size, sizeof(*frames));
+ frames = av_calloc(ctx->initial_pool_size, sizeof(*frames));
if (!frames)
return AVERROR(ENOMEM);
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 272a19da47..8ab96bad25 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -284,7 +284,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
}
}
- hwctx->texture_infos = av_mallocz_array(ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
+ hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
if (!hwctx->texture_infos)
return AVERROR(ENOMEM);
s->nb_surfaces = ctx->initial_pool_size;
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 63b037da4a..f3e578fc10 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -179,8 +179,8 @@ static int dxva2_init_pool(AVHWFramesContext *ctx)
return AVERROR(EINVAL);
}
- s->surfaces_internal = av_mallocz_array(ctx->initial_pool_size,
- sizeof(*s->surfaces_internal));
+ s->surfaces_internal = av_calloc(ctx->initial_pool_size,
+ sizeof(*s->surfaces_internal));
if (!s->surfaces_internal)
return AVERROR(ENOMEM);
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 41fac43229..26a3a24593 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -2441,8 +2441,8 @@ static int opencl_frames_derive_from_dxva2(AVHWFramesContext *dst_fc,
frames_priv->nb_mapped_frames = src_hwctx->nb_surfaces;
frames_priv->mapped_frames =
- av_mallocz_array(frames_priv->nb_mapped_frames,
- sizeof(*frames_priv->mapped_frames));
+ av_calloc(frames_priv->nb_mapped_frames,
+ sizeof(*frames_priv->mapped_frames));
if (!frames_priv->mapped_frames)
return AVERROR(ENOMEM);
@@ -2596,8 +2596,8 @@ static int opencl_frames_derive_from_d3d11(AVHWFramesContext *dst_fc,
frames_priv->nb_mapped_frames = src_fc->initial_pool_size;
frames_priv->mapped_frames =
- av_mallocz_array(frames_priv->nb_mapped_frames,
- sizeof(*frames_priv->mapped_frames));
+ av_calloc(frames_priv->nb_mapped_frames,
+ sizeof(*frames_priv->mapped_frames));
if (!frames_priv->mapped_frames)
return AVERROR(ENOMEM);
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index d431e71eab..225ae768a9 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -437,13 +437,13 @@ static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc)
return AVERROR(EINVAL);
}
- s->handle_pairs_internal = av_mallocz_array(ctx->initial_pool_size,
- sizeof(*s->handle_pairs_internal));
+ s->handle_pairs_internal = av_calloc(ctx->initial_pool_size,
+ sizeof(*s->handle_pairs_internal));
if (!s->handle_pairs_internal)
return AVERROR(ENOMEM);
- s->surfaces_internal = av_mallocz_array(ctx->initial_pool_size,
- sizeof(*s->surfaces_internal));
+ s->surfaces_internal = av_calloc(ctx->initial_pool_size,
+ sizeof(*s->surfaces_internal));
if (!s->surfaces_internal)
return AVERROR(ENOMEM);
@@ -626,8 +626,8 @@ static int qsv_frames_init(AVHWFramesContext *ctx)
}
if (opaque) {
- s->surface_ptrs = av_mallocz_array(frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs));
+ s->surface_ptrs = av_calloc(frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs));
if (!s->surface_ptrs)
return AVERROR(ENOMEM);
@@ -645,7 +645,7 @@ static int qsv_frames_init(AVHWFramesContext *ctx)
s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc;
} else {
- s->mem_ids = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids));
+ s->mem_ids = av_calloc(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids));
if (!s->mem_ids)
return AVERROR(ENOMEM);
@@ -710,8 +710,8 @@ static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx,
case AV_HWDEVICE_TYPE_VAAPI:
{
AVVAAPIFramesContext *dst_hwctx = dst_ctx->hwctx;
- dst_hwctx->surface_ids = av_mallocz_array(src_hwctx->nb_surfaces,
- sizeof(*dst_hwctx->surface_ids));
+ dst_hwctx->surface_ids = av_calloc(src_hwctx->nb_surfaces,
+ sizeof(*dst_hwctx->surface_ids));
if (!dst_hwctx->surface_ids)
return AVERROR(ENOMEM);
for (i = 0; i < src_hwctx->nb_surfaces; i++) {
@@ -738,8 +738,8 @@ static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx,
case AV_HWDEVICE_TYPE_DXVA2:
{
AVDXVA2FramesContext *dst_hwctx = dst_ctx->hwctx;
- dst_hwctx->surfaces = av_mallocz_array(src_hwctx->nb_surfaces,
- sizeof(*dst_hwctx->surfaces));
+ dst_hwctx->surfaces = av_calloc(src_hwctx->nb_surfaces,
+ sizeof(*dst_hwctx->surfaces));
if (!dst_hwctx->surfaces)
return AVERROR(ENOMEM);
for (i = 0; i < src_hwctx->nb_surfaces; i++) {
@@ -1119,11 +1119,12 @@ static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx,
case AV_HWDEVICE_TYPE_VAAPI:
{
AVVAAPIFramesContext *src_hwctx = src_ctx->hwctx;
- s->handle_pairs_internal = av_mallocz_array(src_ctx->initial_pool_size, sizeof(*s->handle_pairs_internal));
+ s->handle_pairs_internal = av_calloc(src_ctx->initial_pool_size,
+ sizeof(*s->handle_pairs_internal));
if (!s->handle_pairs_internal)
return AVERROR(ENOMEM);
- s->surfaces_internal = av_mallocz_array(src_hwctx->nb_surfaces,
- sizeof(*s->surfaces_internal));
+ s->surfaces_internal = av_calloc(src_hwctx->nb_surfaces,
+ sizeof(*s->surfaces_internal));
if (!s->surfaces_internal)
return AVERROR(ENOMEM);
for (i = 0; i < src_hwctx->nb_surfaces; i++) {
@@ -1141,11 +1142,12 @@ static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx,
case AV_HWDEVICE_TYPE_D3D11VA:
{
AVD3D11VAFramesContext *src_hwctx = src_ctx->hwctx;
- s->handle_pairs_internal = av_mallocz_array(src_ctx->initial_pool_size, sizeof(*s->handle_pairs_internal));
+ s->handle_pairs_internal = av_calloc(src_ctx->initial_pool_size,
+ sizeof(*s->handle_pairs_internal));
if (!s->handle_pairs_internal)
return AVERROR(ENOMEM);
- s->surfaces_internal = av_mallocz_array(src_ctx->initial_pool_size,
- sizeof(*s->surfaces_internal));
+ s->surfaces_internal = av_calloc(src_ctx->initial_pool_size,
+ sizeof(*s->surfaces_internal));
if (!s->surfaces_internal)
return AVERROR(ENOMEM);
for (i = 0; i < src_ctx->initial_pool_size; i++) {
@@ -1171,11 +1173,12 @@ static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx,
case AV_HWDEVICE_TYPE_DXVA2:
{
AVDXVA2FramesContext *src_hwctx = src_ctx->hwctx;
- s->handle_pairs_internal = av_mallocz_array(src_ctx->initial_pool_size, sizeof(*s->handle_pairs_internal));
+ s->handle_pairs_internal = av_calloc(src_ctx->initial_pool_size,
+ sizeof(*s->handle_pairs_internal));
if (!s->handle_pairs_internal)
return AVERROR(ENOMEM);
- s->surfaces_internal = av_mallocz_array(src_hwctx->nb_surfaces,
- sizeof(*s->surfaces_internal));
+ s->surfaces_internal = av_calloc(src_hwctx->nb_surfaces,
+ sizeof(*s->surfaces_internal));
if (!s->surfaces_internal)
return AVERROR(ENOMEM);
for (i = 0; i < src_hwctx->nb_surfaces; i++) {
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 94fdad7f06..2c3216857a 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -804,13 +804,13 @@ static int find_device(AVHWDeviceContext *ctx, VulkanDeviceSelection *select)
goto end;
}
- prop = av_mallocz_array(num, sizeof(*prop));
+ prop = av_calloc(num, sizeof(*prop));
if (!prop) {
err = AVERROR(ENOMEM);
goto end;
}
- idp = av_mallocz_array(num, sizeof(*idp));
+ idp = av_calloc(num, sizeof(*idp));
if (!idp) {
err = AVERROR(ENOMEM);
goto end;
diff --git a/libavutil/internal.h b/libavutil/internal.h
index b032e7540a..0a7f1c6257 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -95,7 +95,7 @@
#define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p)))
-#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, sizeof(*p)))
+#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p)))
#define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr))
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index 142d50e7c3..90f082452c 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -32,7 +32,7 @@ static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
*filename_w = NULL;
return 0;
}
- *filename_w = (wchar_t *)av_mallocz_array(num_chars, sizeof(wchar_t));
+ *filename_w = (wchar_t *)av_calloc(num_chars, sizeof(wchar_t));
if (!*filename_w) {
errno = ENOMEM;
return -1;
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index a7bb69dd4f..22c2c33673 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -415,7 +415,7 @@ int swri_realloc_audio(AudioData *a, int count){
av_assert0(a->bps);
av_assert0(a->ch_count);
- a->data= av_mallocz_array(countb, a->ch_count);
+ a->data = av_calloc(countb, a->ch_count);
if(!a->data)
return AVERROR(ENOMEM);
for(i=0; i<a->ch_count; i++){
diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c
index e515e4bcff..0608c74e7f 100644
--- a/libswresample/x86/rematrix_init.c
+++ b/libswresample/x86/rematrix_init.c
@@ -51,7 +51,7 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
s->mix_1_1_simd = ff_mix_1_1_a_int16_sse2;
s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2;
}
- s->native_simd_matrix = av_mallocz_array(num, 2 * sizeof(int16_t));
+ s->native_simd_matrix = av_calloc(num, 2 * sizeof(int16_t));
s->native_simd_one = av_mallocz(2 * sizeof(int16_t));
if (!s->native_simd_matrix || !s->native_simd_one)
return AVERROR(ENOMEM);
@@ -78,7 +78,7 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
s->mix_1_1_simd = ff_mix_1_1_a_float_avx;
s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
}
- s->native_simd_matrix = av_mallocz_array(num, sizeof(float));
+ s->native_simd_matrix = av_calloc(num, sizeof(float));
s->native_simd_one = av_mallocz(sizeof(float));
if (!s->native_simd_matrix || !s->native_simd_one)
return AVERROR(ENOMEM);
diff --git a/libswscale/slice.c b/libswscale/slice.c
index b185b4aa18..b3ee06d632 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -91,7 +91,7 @@ static int alloc_slice(SwsSlice *s, enum AVPixelFormat fmt, int lumLines, int ch
for (i = 0; i < 4; ++i) {
int n = size[i] * ( ring == 0 ? 1 : 3);
- s->plane[i].line = av_mallocz_array(sizeof(uint8_t*), n);
+ s->plane[i].line = av_calloc(n, sizeof(*s->plane[i].line));
if (!s->plane[i].line)
return AVERROR(ENOMEM);
@@ -284,10 +284,10 @@ int ff_init_filters(SwsContext * c)
- c->desc = av_mallocz_array(sizeof(SwsFilterDescriptor), c->numDesc);
+ c->desc = av_calloc(c->numDesc, sizeof(*c->desc));
if (!c->desc)
return AVERROR(ENOMEM);
- c->slice = av_mallocz_array(sizeof(SwsSlice), c->numSlice);
+ c->slice = av_calloc(c->numSlice, sizeof(*c->slice));
if (!c->slice) {
res = AVERROR(ENOMEM);
goto cleanup;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 25051ead72..dab43b5d76 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1204,8 +1204,8 @@ static int context_init_threaded(SwsContext *c,
c->nb_threads = ret;
- c->slice_ctx = av_mallocz_array(c->nb_threads, sizeof(*c->slice_ctx));
- c->slice_err = av_mallocz_array(c->nb_threads, sizeof(*c->slice_err));
+ c->slice_ctx = av_calloc(c->nb_threads, sizeof(*c->slice_ctx));
+ c->slice_err = av_calloc(c->nb_threads, sizeof(*c->slice_err));
if (!c->slice_ctx || !c->slice_err)
return AVERROR(ENOMEM);
diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index 500217239c..9216112b87 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -237,7 +237,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS
desc[1].dst = dst;
}
} else {
- lumCtx = av_mallocz_array(sizeof(VScalerContext), 2);
+ lumCtx = av_calloc(2, sizeof(*lumCtx));
if (!lumCtx)
return AVERROR(ENOMEM);
chrCtx = &lumCtx[1];
diff --git a/tests/api/api-threadmessage-test.c b/tests/api/api-threadmessage-test.c
index b6a74f678b..c96b473c43 100644
--- a/tests/api/api-threadmessage-test.c
+++ b/tests/api/api-threadmessage-test.c
@@ -198,8 +198,8 @@ int main(int ac, char **av)
nb_senders, sender_min_load, sender_max_load,
nb_receivers, receiver_min_load, receiver_max_load);
- senders = av_mallocz_array(nb_senders, sizeof(*senders));
- receivers = av_mallocz_array(nb_receivers, sizeof(*receivers));
+ senders = av_calloc(nb_senders, sizeof(*senders));
+ receivers = av_calloc(nb_receivers, sizeof(*receivers));
if (!senders || !receivers) {
ret = AVERROR(ENOMEM);
goto end;
diff --git a/tests/checkasm/llviddsp.c b/tests/checkasm/llviddsp.c
index 4f75ffc459..66e08c8099 100644
--- a/tests/checkasm/llviddsp.c
+++ b/tests/checkasm/llviddsp.c
@@ -46,8 +46,8 @@ static void check_add_bytes(LLVidDSPContext c, int width)
{
uint8_t *dst0 = av_mallocz(width);
uint8_t *dst1 = av_mallocz(width);
- uint8_t *src0 = av_mallocz_array(width, sizeof(uint8_t));
- uint8_t *src1 = av_mallocz_array(width, sizeof(uint8_t));
+ uint8_t *src0 = av_calloc(width, sizeof(*src0));
+ uint8_t *src1 = av_calloc(width, sizeof(*src1));
declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t w);
init_buffer(src0, src1, uint8_t, width);
@@ -74,10 +74,10 @@ static void check_add_median_pred(LLVidDSPContext c, int width) {
int A0, A1, B0, B1;
uint8_t *dst0 = av_mallocz(width);
uint8_t *dst1 = av_mallocz(width);
- uint8_t *src0 = av_mallocz_array(width, sizeof(uint8_t));
- uint8_t *src1 = av_mallocz_array(width, sizeof(uint8_t));
- uint8_t *diff0 = av_mallocz_array(width, sizeof(uint8_t));
- uint8_t *diff1 = av_mallocz_array(width, sizeof(uint8_t));
+ uint8_t *src0 = av_calloc(width, sizeof(*src0));
+ uint8_t *src1 = av_calloc(width, sizeof(*src1));
+ uint8_t *diff0 = av_calloc(width, sizeof(*diff0));
+ uint8_t *diff1 = av_calloc(width, sizeof(*diff1));
declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src1,
const uint8_t *diff, ptrdiff_t w,
int *left, int *left_top);
@@ -112,8 +112,8 @@ static void check_add_left_pred(LLVidDSPContext c, int width, int acc, const cha
int res0, res1;
uint8_t *dst0 = av_mallocz(width);
uint8_t *dst1 = av_mallocz(width);
- uint8_t *src0 = av_mallocz_array(width, sizeof(uint8_t));
- uint8_t *src1 = av_mallocz_array(width, sizeof(uint8_t));
+ uint8_t *src0 = av_calloc(width, sizeof(*src0));
+ uint8_t *src1 = av_calloc(width, sizeof(*src1));
declare_func_emms(AV_CPU_FLAG_MMX, int, uint8_t *dst, uint8_t *src, ptrdiff_t w, int acc);
init_buffer(src0, src1, uint8_t, width);
@@ -139,10 +139,10 @@ static void check_add_left_pred(LLVidDSPContext c, int width, int acc, const cha
static void check_add_left_pred_16(LLVidDSPContext c, unsigned mask, int width, unsigned acc, const char * report)
{
int res0, res1;
- uint16_t *dst0 = av_mallocz_array(width, sizeof(uint16_t));
- uint16_t *dst1 = av_mallocz_array(width, sizeof(uint16_t));
- uint16_t *src0 = av_mallocz_array(width, sizeof(uint16_t));
- uint16_t *src1 = av_mallocz_array(width, sizeof(uint16_t));
+ uint16_t *dst0 = av_calloc(width, sizeof(*dst0));
+ uint16_t *dst1 = av_calloc(width, sizeof(*dst1));
+ uint16_t *src0 = av_calloc(width, sizeof(*src0));
+ uint16_t *src1 = av_calloc(width, sizeof(*src1));
declare_func_emms(AV_CPU_FLAG_MMX, int, uint16_t *dst, uint16_t *src, unsigned mask, ptrdiff_t w, unsigned acc);
init_buffer(src0, src1, uint16_t, width);
diff --git a/tests/checkasm/vf_nlmeans.c b/tests/checkasm/vf_nlmeans.c
index 32c6931a4b..87474d6803 100644
--- a/tests/checkasm/vf_nlmeans.c
+++ b/tests/checkasm/vf_nlmeans.c
@@ -46,12 +46,12 @@ void checkasm_check_nlmeans(void)
const int ii_w = w + e*2;
const int ii_h = h + e*2;
const int ii_lz_32 = FFALIGN(ii_w + 1, 4);
- uint32_t *ii_orig_ref = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_ref));
+ uint32_t *ii_orig_ref = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_ref));
uint32_t *ii_ref = ii_orig_ref + ii_lz_32 + 1;
- uint32_t *ii_orig_new = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_new));
+ uint32_t *ii_orig_new = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_new));
uint32_t *ii_new = ii_orig_new + ii_lz_32 + 1;
const int src_lz = FFALIGN(w, 16);
- uint8_t *src = av_mallocz_array(h, src_lz);
+ uint8_t *src = av_calloc(h, src_lz);
declare_func(void, uint32_t *dst, ptrdiff_t dst_linesize_32,
const uint8_t *s1, ptrdiff_t linesize1,
diff --git a/tools/ismindex.c b/tools/ismindex.c
index 7601f62e06..d355cffe38 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -342,7 +342,7 @@ static int read_tfra(struct Tracks *tracks, int start_index, AVIOContext *f)
}
fieldlength = avio_rb32(f);
track->chunks = avio_rb32(f);
- track->offsets = av_mallocz_array(track->chunks, sizeof(*track->offsets));
+ track->offsets = av_calloc(track->chunks, sizeof(*track->offsets));
if (!track->offsets) {
track->chunks = 0;
ret = AVERROR(ENOMEM);
--
2.30.2
More information about the ffmpeg-devel
mailing list