Mercurial > libavutil.hg
changeset 772:988be4b2fd0c libavutil
Add CHECKED_ALLOC macro.
It works the same as CHECKED_ALLOCZ except that it does not zero the allocated
memory.
author | ramiro |
---|---|
date | Sat, 29 Aug 2009 22:38:48 +0000 |
parents | c2556eaf12ca |
children | 8848af31706f |
files | internal.h |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/internal.h Mon Aug 17 00:15:53 2009 +0000 +++ b/internal.h Sat Aug 29 22:38:48 2009 +0000 @@ -249,6 +249,15 @@ #define perror please_use_av_log_instead_of_perror #endif +#define CHECKED_ALLOC(p, size)\ +{\ + p= av_malloc(size);\ + if(p==NULL && (size)!=0){\ + av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ + goto fail;\ + }\ +} + #define CHECKED_ALLOCZ(p, size)\ {\ p= av_mallocz(size);\