Libav 0.7.1
|
00001 /* 00002 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> 00003 * 00004 * This file is part of Libav. 00005 * 00006 * Libav is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * Libav is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with Libav; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 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 00073 void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); 00074 00087 void *av_realloc(void *ptr, size_t size) av_alloc_size(2); 00088 00097 void av_free(void *ptr); 00098 00107 void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); 00108 00115 char *av_strdup(const char *s) av_malloc_attrib; 00116 00124 void av_freep(void *ptr); 00125 00126 #endif /* AVUTIL_MEM_H */