You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavu/mem: un-inline av_size_mult()
There seems to be no compelling reason for it to be inline.
This commit is contained in:
@@ -547,3 +547,21 @@ void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
|
|||||||
{
|
{
|
||||||
fast_malloc(ptr, size, min_size, 1);
|
fast_malloc(ptr, size, min_size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int av_size_mult(size_t a, size_t b, size_t *r)
|
||||||
|
{
|
||||||
|
size_t t;
|
||||||
|
|
||||||
|
#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow)
|
||||||
|
if (__builtin_mul_overflow(a, b, &t))
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
#else
|
||||||
|
t = a * b;
|
||||||
|
/* Hack inspired from glibc: don't try the division if nelem and elsize
|
||||||
|
* are both less than sqrt(SIZE_MAX). */
|
||||||
|
if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
#endif
|
||||||
|
*r = t;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "attributes.h"
|
#include "attributes.h"
|
||||||
#include "error.h"
|
|
||||||
#include "avutil.h"
|
#include "avutil.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@@ -672,23 +671,7 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
|
|||||||
* @param[out] r Pointer to the result of the operation
|
* @param[out] r Pointer to the result of the operation
|
||||||
* @return 0 on success, AVERROR(EINVAL) on overflow
|
* @return 0 on success, AVERROR(EINVAL) on overflow
|
||||||
*/
|
*/
|
||||||
static inline int av_size_mult(size_t a, size_t b, size_t *r)
|
int av_size_mult(size_t a, size_t b, size_t *r);
|
||||||
{
|
|
||||||
size_t t;
|
|
||||||
|
|
||||||
#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow)
|
|
||||||
if (__builtin_mul_overflow(a, b, &t))
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
#else
|
|
||||||
t = a * b;
|
|
||||||
/* Hack inspired from glibc: don't try the division if nelem and elsize
|
|
||||||
* are both less than sqrt(SIZE_MAX). */
|
|
||||||
if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
#endif
|
|
||||||
*r = t;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum size that may be allocated in one block.
|
* Set the maximum size that may be allocated in one block.
|
||||||
|
Reference in New Issue
Block a user