diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-18 15:25:00 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-22 02:09:55 +0200 |
commit | 47ec0b0b0f213718b80cd614f1b9dfeec1410ed1 (patch) | |
tree | e37ee57085b0f25d12e028484ede944a3c8d2b47 | |
parent | 5e5aced585b30ca97a2fc0d03fce1c721d114864 (diff) | |
download | ffmpeg-47ec0b0b0f213718b80cd614f1b9dfeec1410ed1.tar.gz |
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@gmx.at>
-rw-r--r-- | libavutil/internal.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavutil/internal.h b/libavutil/internal.h index 9c5546f3b1..c6c0aa8d38 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) |