diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-07-10 03:49:44 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2012-07-10 21:42:23 +0000 |
commit | 0e003d8c91b85a2ec49f7a653f9c6f93d025bf5a (patch) | |
tree | 9ec2ba88f58170dbe598b1cb4f3701094d8a6516 /libavcodec/utils.c | |
parent | ca16f88c75f84a054d6bd71fe3f6fbaf508a1623 (diff) | |
download | ffmpeg-0e003d8c91b85a2ec49f7a653f9c6f93d025bf5a.tar.gz |
lavc: add av_fast_padded_mallocz
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ddd63db331..a326815bc4 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -100,6 +100,18 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) memset(*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); } +void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size) +{ + uint8_t **p = ptr; + if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + av_freep(p); + *size = 0; + return; + } + if (!ff_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE, 1)) + memset(*p, 0, min_size + FF_INPUT_BUFFER_PADDING_SIZE); +} + /* encoder management */ static AVCodec *first_avcodec = NULL; |