#define DECLARE_ASM_CONST(n,t,v) static const t v
#endif
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
#define av_malloc_attrib __attribute__((__malloc__))
#else
#define av_malloc_attrib
#endif
+#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2)
+ #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).
* 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.
* 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
* 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.