mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
mem: add av_max_alloc() to limit the maximum amount that may be allocated in one piece
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
5e9a56a035
commit
5a8e994287
@ -154,7 +154,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 51
|
#define LIBAVUTIL_VERSION_MAJOR 51
|
||||||
#define LIBAVUTIL_VERSION_MINOR 32
|
#define LIBAVUTIL_VERSION_MINOR 33
|
||||||
#define LIBAVUTIL_VERSION_MICRO 100
|
#define LIBAVUTIL_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
|
@ -65,7 +65,11 @@ void free(void *ptr);
|
|||||||
memory allocator. You do not need to suppress this file because the
|
memory allocator. You do not need to suppress this file because the
|
||||||
linker will do it automatically. */
|
linker will do it automatically. */
|
||||||
|
|
||||||
#define MAX_MALLOC_SIZE INT_MAX
|
static size_t max_alloc_size= INT_MAX;
|
||||||
|
|
||||||
|
void av_max_alloc(size_t max){
|
||||||
|
max_alloc_size = max;
|
||||||
|
}
|
||||||
|
|
||||||
void *av_malloc(size_t size)
|
void *av_malloc(size_t size)
|
||||||
{
|
{
|
||||||
@ -75,7 +79,7 @@ void *av_malloc(size_t size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* let's disallow possible ambiguous cases */
|
/* let's disallow possible ambiguous cases */
|
||||||
if (size > (MAX_MALLOC_SIZE-32))
|
if (size > (max_alloc_size-32))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if CONFIG_MEMALIGN_HACK
|
#if CONFIG_MEMALIGN_HACK
|
||||||
@ -130,7 +134,7 @@ void *av_realloc(void *ptr, size_t size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* let's disallow possible ambiguous cases */
|
/* let's disallow possible ambiguous cases */
|
||||||
if (size > (MAX_MALLOC_SIZE-16))
|
if (size > (max_alloc_size-32))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if CONFIG_MEMALIGN_HACK
|
#if CONFIG_MEMALIGN_HACK
|
||||||
|
@ -176,6 +176,11 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the maximum size that may me allocated in one block.
|
||||||
|
*/
|
||||||
|
void av_max_alloc(size_t max);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user