#if AV_GCC_VERSION_AT_LEAST(4,3)
#define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
#else
#define av_alloc_size(...)
#endif
/**
* 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) static inline void *av_mallocz_array(size_t nmemb,
size_t size)
{
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_mallocz(nmemb * size);
}
I am a c lang primer. I see this function when I read open source. but what kind of function is it? I have never seen this kind of function before. av_alloc_size(1, 2)
and *av_mallocz_array
have any relationship?