changeset 113:8fc54918226e libavutil

move memory functions from avcodec to avutil
author lu_zero
date Mon, 25 Sep 2006 15:23:40 +0000
parents aedf5cf3de93
children 37779851c665
files avutil.h common.h mem.c
diffstat 3 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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 */
--- 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;
+}
+