]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/mem.h
Merge remote-tracking branch 'richardpl/escape130'
[ffmpeg] / libavutil / mem.h
index ffdbb98d94b984cdf02a2f15d93cb1bc76c3700a..f148c637bb61931f865e94d88ad2aa668b8f97e6 100644 (file)
 #include "error.h"
 #include "avutil.h"
 
+/**
+ * @addtogroup lavu_mem
+ * @{
+ */
+
+
 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
     #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
     #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
@@ -87,6 +93,16 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
  */
 void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
 
+/**
+ * Allocate or reallocate a block of memory.
+ * This function does the same thing as av_realloc, except:
+ * - It takes two arguments and checks the result of the multiplication for
+ *   integer overflow.
+ * - It frees the input block in case of failure, thus avoiding the memory
+ *   leak with the classic "buf = realloc(buf); if (!buf) return -1;".
+ */
+void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
+
 /**
  * Free a memory block which has been allocated with av_malloc(z)() or
  * av_realloc().
@@ -160,4 +176,8 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
     return 0;
 }
 
+/**
+ * @}
+ */
+
 #endif /* AVUTIL_MEM_H */