From: Panagiotis Issaris Date: Mon, 12 Mar 2007 14:45:49 +0000 (+0000) Subject: Move the memory related functions out of common.h into their own header file X-Git-Tag: v0.5~9705 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=792098c2ec867e151b8457d6b99978cd074db04e;p=coroid%2Flibav_saccubus.git Move the memory related functions out of common.h into their own header file mem.h. Originally committed as revision 8342 to svn://svn.ffmpeg.org/ffmpeg/trunk --- diff --git a/libavutil/common.h b/libavutil/common.h index 84e6e19e4..9ec5c7c78 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -63,6 +63,8 @@ #endif #endif +#include "mem.h" + //rounded divison & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) /* assume b>0 */ @@ -321,44 +323,4 @@ tend= read_time();\ #define STOP_TIMER(id) {} #endif -/* memory */ - -#ifdef __GNUC__ - #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) -#else - #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v -#endif - -/* memory */ - -/** - * Memory allocation of size byte with alignment suitable for all - * memory accesses (including vectors if available on the - * CPU). av_malloc(0) must return a non NULL pointer. - */ -void *av_malloc(unsigned int size); - -/** - * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, - * identical to malloc(size). If size is zero, it is identical to - * free(ptr) and NULL is returned. - */ -void *av_realloc(void *ptr, unsigned int size); - -/** - * Free memory which has been allocated with av_malloc(z)() or av_realloc(). - * NOTE: ptr = NULL is explicetly allowed - * Note2: it is recommended that you use av_freep() instead - */ -void av_free(void *ptr); - -void *av_mallocz(unsigned int size); -char *av_strdup(const char *s); - -/** - * Frees memory and sets the pointer to NULL. - * @param ptr pointer to the pointer which should be freed - */ -void av_freep(void *ptr); - #endif /* COMMON_H */ diff --git a/libavutil/mem.h b/libavutil/mem.h new file mode 100644 index 000000000..4ebdad8f5 --- /dev/null +++ b/libavutil/mem.h @@ -0,0 +1,65 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file mem.h + * Memory handling functions. + */ + +#ifndef AV_MEM_H +#define AV_MEM_H + +#ifdef __GNUC__ + #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) +#else + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v +#endif + +/** + * Memory allocation of size byte with alignment suitable for all + * memory accesses (including vectors if available on the + * CPU). av_malloc(0) must return a non NULL pointer. + */ +void *av_malloc(unsigned int size); + +/** + * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, + * identical to malloc(size). If size is zero, it is identical to + * free(ptr) and NULL is returned. + */ +void *av_realloc(void *ptr, unsigned int size); + +/** + * Free memory which has been allocated with av_malloc(z)() or av_realloc(). + * NOTE: ptr = NULL is explicetly allowed + * Note2: it is recommended that you use av_freep() instead + */ +void av_free(void *ptr); + +void *av_mallocz(unsigned int size); +char *av_strdup(const char *s); + +/** + * Frees memory and sets the pointer to NULL. + * @param ptr pointer to the pointer which should be freed + */ +void av_freep(void *ptr); + +#endif /* AV_MEM_H */