00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifndef AVUTIL_MEM_H
00027 #define AVUTIL_MEM_H
00028
00029 #include "attributes.h"
00030
00031 #if defined(__ICC) || defined(__SUNPRO_C)
00032 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
00033 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
00034 #elif defined(__TI_COMPILER_VERSION__)
00035 #define DECLARE_ALIGNED(n,t,v) \
00036 AV_PRAGMA(DATA_ALIGN(v,n)) \
00037 t __attribute__((aligned(n))) v
00038 #define DECLARE_ASM_CONST(n,t,v) \
00039 AV_PRAGMA(DATA_ALIGN(v,n)) \
00040 static const t __attribute__((aligned(n))) v
00041 #elif defined(__GNUC__)
00042 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
00043 #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
00044 #elif defined(_MSC_VER)
00045 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
00046 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
00047 #else
00048 #define DECLARE_ALIGNED(n,t,v) t v
00049 #define DECLARE_ASM_CONST(n,t,v) static const t v
00050 #endif
00051
00052 #if AV_GCC_VERSION_AT_LEAST(3,1)
00053 #define av_malloc_attrib __attribute__((__malloc__))
00054 #else
00055 #define av_malloc_attrib
00056 #endif
00057
00058 #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
00059 #define av_alloc_size(n) __attribute__((alloc_size(n)))
00060 #else
00061 #define av_alloc_size(n)
00062 #endif
00063
00072 void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
00073
00086 void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
00087
00096 void av_free(void *ptr);
00097
00106 void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
00107
00114 char *av_strdup(const char *s) av_malloc_attrib;
00115
00123 void av_freep(void *ptr);
00124
00125 #endif