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 #include "avutil.h"
00031
00032 #if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C)
00033 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
00034 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
00035 #elif defined(__TI_COMPILER_VERSION__)
00036 #define DECLARE_ALIGNED(n,t,v) \
00037 AV_PRAGMA(DATA_ALIGN(v,n)) \
00038 t __attribute__((aligned(n))) v
00039 #define DECLARE_ASM_CONST(n,t,v) \
00040 AV_PRAGMA(DATA_ALIGN(v,n)) \
00041 static const t __attribute__((aligned(n))) v
00042 #elif defined(__GNUC__)
00043 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
00044 #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
00045 #elif defined(_MSC_VER)
00046 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
00047 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
00048 #else
00049 #define DECLARE_ALIGNED(n,t,v) t v
00050 #define DECLARE_ASM_CONST(n,t,v) static const t v
00051 #endif
00052
00053 #if AV_GCC_VERSION_AT_LEAST(3,1)
00054 #define av_malloc_attrib __attribute__((__malloc__))
00055 #else
00056 #define av_malloc_attrib
00057 #endif
00058
00059 #if (!defined(__ICC) || __ICC > 1200) && AV_GCC_VERSION_AT_LEAST(4,3)
00060 #define av_alloc_size(n) __attribute__((alloc_size(n)))
00061 #else
00062 #define av_alloc_size(n)
00063 #endif
00064
00065 #if LIBAVUTIL_VERSION_MAJOR < 51
00066 # define FF_INTERNAL_MEM_TYPE unsigned int
00067 # define FF_INTERNAL_MEM_TYPE_MAX_VALUE UINT_MAX
00068 #else
00069 # define FF_INTERNAL_MEM_TYPE size_t
00070 # define FF_INTERNAL_MEM_TYPE_MAX_VALUE SIZE_MAX
00071 #endif
00072
00081 void *av_malloc(FF_INTERNAL_MEM_TYPE size) av_malloc_attrib av_alloc_size(1);
00082
00095 void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size) av_alloc_size(2);
00096
00105 void av_free(void *ptr);
00106
00115 void *av_mallocz(FF_INTERNAL_MEM_TYPE size) av_malloc_attrib av_alloc_size(1);
00116
00123 char *av_strdup(const char *s) av_malloc_attrib;
00124
00132 void av_freep(void *ptr);
00133
00134 #endif