diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-09-15 21:42:07 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-09-16 19:36:37 +0200 |
commit | 3feb3d6ce4be0a09a9f8f13d613bed25b523b6e7 (patch) | |
tree | dea7915eef1bacbb21952741c5b90e17c8c45541 /libavutil/mem.c | |
parent | 187105ff8a02bafc9c58d9d8363bb3f55a415635 (diff) | |
download | ffmpeg-3feb3d6ce4be0a09a9f8f13d613bed25b523b6e7.tar.gz |
mem: Introduce av_reallocp
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r-- | libavutil/mem.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c index 5f64f56a0d..172180e7b9 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -136,6 +136,22 @@ void *av_realloc(void *ptr, size_t size) #endif } +int av_reallocp(void *ptr, size_t size) +{ + void **ptrptr = ptr; + void *ret; + + ret = av_realloc(*ptrptr, size); + + if (!ret) { + av_freep(ptr); + return AVERROR(ENOMEM); + } + + *ptrptr = ret; + return 0; +} + void *av_realloc_array(void *ptr, size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) |