Mercurial > libavcodec.hg
diff utils.c @ 9415:141badec76fc libavcodec
Add a av_fast_malloc function and replace several uses of av_fast_realloc,
thus avoiding potential memleaks and pointless memcpys.
author | reimar |
---|---|
date | Sun, 12 Apr 2009 13:17:37 +0000 |
parents | d31c367da415 |
children | f522c8e05a29 |
line wrap: on
line diff
--- a/utils.c Sun Apr 12 12:25:53 2009 +0000 +++ b/utils.c Sun Apr 12 13:17:37 2009 +0000 @@ -80,6 +80,17 @@ return ptr; } +void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size) +{ + void **p = ptr; + if (min_size < *size) + return; + *size= FFMAX(17*min_size/16 + 32, min_size); + av_free(*p); + *p = av_malloc(*size); + if (!*p) *size = 0; +} + /* encoder management */ static AVCodec *first_avcodec = NULL;