]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/mem.c
intreadwrite: common.h is not needed, attributes.h is sufficient
[ffmpeg] / libavutil / mem.c
index 9268ab4dfc20c862b75b7a87fb9694f25c780917..8cad089a7db29d790ae707628602dde646eb48d0 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file mem.c
+ * @file
  * default memory allocator for libavutil
  */
 
@@ -33,6 +33,7 @@
 #include <malloc.h>
 #endif
 
+#include "avutil.h"
 #include "mem.h"
 
 /* here we can use OS-dependent allocation functions */
 #undef malloc
 #undef realloc
 
+#ifdef MALLOC_PREFIX
+
+#define malloc         AV_JOIN(MALLOC_PREFIX, malloc)
+#define memalign       AV_JOIN(MALLOC_PREFIX, memalign)
+#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
+#define realloc        AV_JOIN(MALLOC_PREFIX, realloc)
+#define free           AV_JOIN(MALLOC_PREFIX, free)
+
+void *malloc(size_t size);
+void *memalign(size_t align, size_t size);
+int   posix_memalign(void **ptr, size_t align, size_t size);
+void *realloc(void *ptr, size_t size);
+void  free(void *ptr);
+
+#endif /* MALLOC_PREFIX */
+
 /* You can redefine av_malloc and av_free in your project to use your
    memory allocator. You do not need to suppress this file because the
    linker will do it automatically. */
@@ -63,7 +80,8 @@ void *av_malloc(unsigned int size)
     ptr = (char*)ptr + diff;
     ((char*)ptr)[-1]= diff;
 #elif HAVE_POSIX_MEMALIGN
-    posix_memalign(&ptr,16,size);
+    if (posix_memalign(&ptr,16,size))
+        ptr = NULL;
 #elif HAVE_MEMALIGN
     ptr = memalign(16,size);
     /* Why 64?