diff options
author | Zuxy Meng <zuxy.meng@gmail.com> | 2008-03-19 07:30:34 +0000 |
---|---|---|
committer | Zuxy Meng <zuxy.meng@gmail.com> | 2008-03-19 07:30:34 +0000 |
commit | cca6d953c243dbb05d7cc7a4d26d90c99173bf2c (patch) | |
tree | 51168658f1a36a18d93cd1bb37de0a5baf3a419b | |
parent | 85074d3c9388123d792995c8f98c9b5d807566b4 (diff) | |
download | ffmpeg-cca6d953c243dbb05d7cc7a4d26d90c99173bf2c.tar.gz |
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
Originally committed as revision 12499 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavutil/mem.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libavutil/mem.h b/libavutil/mem.h index c68117d43d..d73e225b25 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -48,6 +48,12 @@ #define av_malloc_attrib #endif +#if defined (__GNUC__) && (__GNU__ > 4 || __GNU__ == 4 && __GNU_MINOR__ > 1) + #define av_alloc_size(n) __attribute__((alloc_size(n))) +#else + #define av_alloc_size(n) +#endif + /** * Allocate a block of \p size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU). @@ -56,7 +62,7 @@ * it. * @see av_mallocz() */ -void *av_malloc(unsigned int size) av_malloc_attrib; +void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); /** * Allocate or reallocate a block of memory. @@ -70,7 +76,7 @@ void *av_malloc(unsigned int size) av_malloc_attrib; * reallocate or the function is used to free the memory block. * @see av_fast_realloc() */ -void *av_realloc(void *ptr, unsigned int size); +void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); /** * Free a memory block which has been allocated with av_malloc(z)() or @@ -91,7 +97,7 @@ void av_free(void *ptr); * it. * @see av_malloc() */ -void *av_mallocz(unsigned int size) av_malloc_attrib; +void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); /** * Duplicate the string \p s. |