[FFmpeg-devel] av_mallocz_array

Hendrik Leppkes h.leppkes at gmail.com
Thu May 4 13:13:35 EEST 2023


On Thu, May 4, 2023 at 11:06 AM Christophe GARNIER
<garnierchris at numericable.fr> wrote:
>
> Hello,
>
> To build makemkv version 1.17.3 (makemkv-oss), I retreived he sources of
> ffmpeg from the git repository (git clone
> https://git.ffmpeg.org/ffmpeg.git ffmpeg).It appeared that the function
> av_mallocz_array is not present into libavutil/mem.c and libavutil/mem.h.
>
> I had the following code into libavutil/mem.c :
>
> void *av_mallocz_array(size_t nmemb, size_t size)
> {
>     size_t result;
>     if (size_mult(nmemb, size, &result) < 0)
>         return NULL;
>     return av_mallocz(result);
> }
>
> and into libavutil/mem.h :
>
> /**
> * Allocate a memory block for an array with av_mallocz().
> *
> * The allocated memory will have size `size * nmemb` bytes.
> *
> * @param nmemb Number of elements
> * @param size  Size of the single element
> * @return Pointer to the allocated block, or `NULL` if the block cannot
> *         be allocated
> *
> * @see av_mallocz()
> * @see av_malloc_array()
> */
> av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size);
>
> After these modifications, I have been able to generate makemkv-oss.
>
>

av_mallocz_array has been deprecated over 2 years ago and removed in
the latest version. The replacement is av_calloc.
The code you are trying to compile needs to be updated for the latest
version of FFmpeg, not the function returned.

- Hendrik


More information about the ffmpeg-devel mailing list