Commit 4959f18a authored by James Almer's avatar James Almer

Merge commit '04b0f0e3'

* commit '04b0f0e3':
  mem: uninline av_malloc(z)_array()
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
parents f9c3fbc0 04b0f0e3
...@@ -181,6 +181,20 @@ int av_reallocp(void *ptr, size_t size) ...@@ -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)
......
...@@ -206,12 +206,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); ...@@ -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 ...@@ -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().
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment