Libav
|
00001 /* 00002 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> 00003 * 00004 * This file is part of FFmpeg. 00005 * 00006 * FFmpeg 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 * FFmpeg 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 FFmpeg; 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 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 /* AVUTIL_MEM_H */