mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-24 08:12:44 +00:00
Add av_calloc() helper.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
35cb6854bb
commit
ccecab4a0d
@ -168,6 +168,13 @@ void *av_mallocz(size_t size)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *av_calloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
if (size <= 0 || nmemb >= INT_MAX / size)
|
||||||
|
return NULL;
|
||||||
|
return av_mallocz(nmemb * size);
|
||||||
|
}
|
||||||
|
|
||||||
char *av_strdup(const char *s)
|
char *av_strdup(const char *s)
|
||||||
{
|
{
|
||||||
char *ptr= NULL;
|
char *ptr= NULL;
|
||||||
|
@ -106,6 +106,18 @@ void av_free(void *ptr);
|
|||||||
*/
|
*/
|
||||||
void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate a block of nmemb * size bytes with alignment suitable for all
|
||||||
|
* memory accesses (including vectors if available on the CPU) and
|
||||||
|
* zero all the bytes of the block.
|
||||||
|
* The allocation will fail if nmemb * size is greater than or equal
|
||||||
|
* to INT_MAX.
|
||||||
|
* @param nmemb
|
||||||
|
* @param size
|
||||||
|
* @return Pointer to the allocated block, NULL if it cannot be allocated.
|
||||||
|
*/
|
||||||
|
void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate the string s.
|
* Duplicate the string s.
|
||||||
* @param s string to be duplicated
|
* @param s string to be duplicated
|
||||||
|
Loading…
Reference in New Issue
Block a user