[FFmpeg-devel] [PATCH] avutil/internal: add FF_ALLOC_ARRAY_OR_GOTO & FF_ALLOCZ_ARRAY_OR_GOTO
Michael Niedermayer
michaelni at gmx.at
Fri Apr 18 15:26:04 CEST 2014
These are similar to the existing FF_ALLOCZ_OR_GOTO & FF_ALLOC_OR_GOTO
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavutil/internal.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 9c5546f..05a017f 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -133,6 +133,24 @@
}\
}
+#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, size0, size1, label)\
+{\
+ p = av_malloc(size0, size1);\
+ if (p == NULL) {\
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+ goto label;\
+ }\
+}
+
+#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, size0, size1, label)\
+{\
+ p = av_mallocz(size0, size1);\
+ if (p == NULL) {\
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
+ goto label;\
+ }\
+}
+
#include "libm.h"
#if defined(_MSC_VER)
--
1.7.9.5
More information about the ffmpeg-devel
mailing list