summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-14 21:31:53 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-20 01:03:52 +0200
commit1ea365082318f06cd42a8b37dd0c7724b599c821 (patch)
tree4df48a8b9f4614803fd2a88c29ad2ff7f7070294 /libavutil
parent4b154743163ffbe3fdc50759c0c55dc854636488 (diff)
Replace all occurences of av_mallocz_array() by av_calloc()
They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/audio_fifo.c2
-rw-r--r--libavutil/encryption_info.c4
-rw-r--r--libavutil/frame.c8
-rw-r--r--libavutil/hwcontext.c2
-rw-r--r--libavutil/hwcontext_d3d11va.c2
-rw-r--r--libavutil/hwcontext_dxva2.c4
-rw-r--r--libavutil/hwcontext_opencl.c8
-rw-r--r--libavutil/hwcontext_qsv.c43
-rw-r--r--libavutil/hwcontext_vulkan.c4
-rw-r--r--libavutil/internal.h2
-rw-r--r--libavutil/wchar_filename.h2
11 files changed, 42 insertions, 39 deletions
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;