diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2006-09-25 15:23:40 +0000 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2006-09-25 15:23:40 +0000 |
commit | 79e47000c8847cc70acf6b7debac10add2e88a81 (patch) | |
tree | cc10b5acc1a3d175444e45d948aa831993073122 /libavutil | |
parent | 10aa27db712fce3a3c8e67a66ff72fcd879bcddf (diff) | |
download | ffmpeg-79e47000c8847cc70acf6b7debac10add2e88a81.tar.gz |
move memory functions from avcodec to avutil
Originally committed as revision 6330 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/avutil.h | 4 | ||||
-rw-r--r-- | libavutil/common.h | 5 | ||||
-rw-r--r-- | libavutil/mem.c | 32 |
3 files changed, 39 insertions, 2 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h index e575aadf21..d75c5ca97e 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -32,8 +32,8 @@ extern "C" { #define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_TOSTRING(s) #s -#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+0) -#define LIBAVUTIL_VERSION 49.0.0 +#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+1) +#define LIBAVUTIL_VERSION 49.0.1 #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) diff --git a/libavutil/common.h b/libavutil/common.h index bd92dda154..d723520d1c 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -403,8 +403,13 @@ tend= read_time();\ #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v #endif +/* memory */ void *av_malloc(unsigned int size); void *av_realloc(void *ptr, unsigned int size); void av_free(void *ptr); +void *av_mallocz(unsigned int size); +char *av_strdup(const char *s); +void av_freep(void *ptr); + #endif /* COMMON_H */ diff --git a/libavutil/mem.c b/libavutil/mem.c index 440328b7f1..33c249c421 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -135,3 +135,35 @@ void av_free(void *ptr) #endif } +/** + * Frees memory and sets the pointer to NULL. + * @param arg pointer to the pointer which should be freed + */ +void av_freep(void *arg) +{ + void **ptr= (void**)arg; + av_free(*ptr); + *ptr = NULL; +} + +void *av_mallocz(unsigned int size) +{ + void *ptr; + + ptr = av_malloc(size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +char *av_strdup(const char *s) +{ + char *ptr; + int len; + len = strlen(s) + 1; + ptr = av_malloc(len); + if (ptr) + memcpy(ptr, s, len); + return ptr; +} + |