1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '04b0f0e371ff81b682274b574fb465ba4395c09f'

* commit '04b0f0e371ff81b682274b574fb465ba4395c09f':
  mem: uninline av_malloc(z)_array()

Merged-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2017-10-30 16:08:14 -03:00
commit 4959f18a8e
2 changed files with 16 additions and 12 deletions

View File

@ -181,6 +181,20 @@ int av_reallocp(void *ptr, size_t size)
return 0; return 0;
} }
void *av_malloc_array(size_t nmemb, size_t size)
{
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_malloc(nmemb * size);
}
void *av_mallocz_array(size_t nmemb, size_t size)
{
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_mallocz(nmemb * size);
}
void *av_realloc_array(void *ptr, size_t nmemb, size_t size) void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
{ {
if (!size || nmemb >= INT_MAX / size) if (!size || nmemb >= INT_MAX / size)

View File

@ -206,12 +206,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
* be allocated * be allocated
* @see av_malloc() * @see av_malloc()
*/ */
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size);
{
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_malloc(nmemb * size);
}
/** /**
* Allocate a memory block for an array with av_mallocz(). * Allocate a memory block for an array with av_mallocz().
@ -226,12 +221,7 @@ av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t siz
* @see av_mallocz() * @see av_mallocz()
* @see av_malloc_array() * @see av_malloc_array()
*/ */
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size);
{
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_mallocz(nmemb * size);
}
/** /**
* Non-inlined equivalent of av_mallocz_array(). * Non-inlined equivalent of av_mallocz_array().