[FFmpeg-devel] av_mallocz_array

James Almer jamrial at gmail.com
Wed Mar 15 23:41:43 EET 2023


On 3/15/2023 6:40 PM, Christophe GARNIER 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.

Use av_calloc() instead.


More information about the ffmpeg-devel mailing list