[FFmpeg-cvslog] avutil/internal: add FF_ALLOC_ARRAY_OR_GOTO & FF_ALLOCZ_ARRAY_OR_GOTO
Michael Niedermayer
git at videolan.org
Tue Apr 22 02:26:29 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Apr 18 15:25:00 2014 +0200| [47ec0b0b0f213718b80cd614f1b9dfeec1410ed1] | committer: Michael Niedermayer
avutil/internal: add FF_ALLOC_ARRAY_OR_GOTO & FF_ALLOCZ_ARRAY_OR_GOTO
These are similar to the existing FF_ALLOCZ_OR_GOTO & FF_ALLOC_OR_GOTO
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47ec0b0b0f213718b80cd614f1b9dfeec1410ed1
---
libavutil/internal.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 9c5546f..c6c0aa8 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -133,6 +133,24 @@
}\
}
+#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\
+{\
+ p = av_malloc_array(nelem, elsize);\
+ if (p == NULL) {\
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+ goto label;\
+ }\
+}
+
+#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\
+{\
+ p = av_mallocz_array(nelem, elsize);\
+ if (p == NULL) {\
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+ goto label;\
+ }\
+}
+
#include "libm.h"
#if defined(_MSC_VER)
More information about the ffmpeg-cvslog
mailing list