diff mem.c @ 113:8fc54918226e libavutil

move memory functions from avcodec to avutil
author lu_zero
date Mon, 25 Sep 2006 15:23:40 +0000
parents 7d343463873b
children d76a36742464
line wrap: on
line diff
--- 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;
+}
+