Skip to content

Commit

Permalink
Replace all occurences of av_mallocz_array() by av_calloc()
Browse files Browse the repository at this point in the history
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
  • Loading branch information
mkver committed Sep 19, 2021
1 parent 4b15474 commit 1ea3650
Show file tree
Hide file tree
Showing 131 changed files with 302 additions and 301 deletions.
2 changes: 1 addition & 1 deletion compat/w32dlfcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/remuxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/transcoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions fftools/cmdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions fftools/ffmpeg_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
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));
Expand All @@ -2604,7 +2604,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
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));
Expand All @@ -2615,7 +2615,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
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,
Expand All @@ -2627,7 +2627,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
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,
Expand Down
3 changes: 1 addition & 2 deletions fftools/ffprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/a64multienc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/aacpsy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 7 additions & 8 deletions libavcodec/alsdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));

Expand All @@ -2102,15 +2101,15 @@ 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) {
ctx->acf = av_malloc_array(avctx->channels, sizeof(*ctx->acf));
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));
Expand All @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/atrac3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/atrac3plusdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions libavcodec/cavs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions libavcodec/cfhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/cfhdenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions libavcodec/cngdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/diracdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/dnxhddec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/dvbsubdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/dxva2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/exr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/ffv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/g2meet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/h264dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions libavcodec/hevcdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions libavcodec/ivi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 1ea3650

Please sign in to comment.