# HG changeset patch # User lu_zero # Date 1159197820 0 # Node ID 8fc54918226ee229ec4b2166bef202eb14cebd53 # Parent aedf5cf3de93382c335fb773ebaef02c20b8d7c4 move memory functions from avcodec to avutil diff -r aedf5cf3de93 -r 8fc54918226e avutil.h --- a/avutil.h Thu Sep 21 18:00:05 2006 +0000 +++ b/avutil.h Mon Sep 25 15:23:40 2006 +0000 @@ -32,8 +32,8 @@ #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 -r aedf5cf3de93 -r 8fc54918226e common.h --- a/common.h Thu Sep 21 18:00:05 2006 +0000 +++ b/common.h Mon Sep 25 15:23:40 2006 +0000 @@ -403,8 +403,13 @@ #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 -r aedf5cf3de93 -r 8fc54918226e mem.c --- a/mem.c Thu Sep 21 18:00:05 2006 +0000 +++ b/mem.c Mon Sep 25 15:23:40 2006 +0000 @@ -135,3 +135,35 @@ #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; +} +