Add a av_fast_malloc function and replace several uses of av_fast_realloc,

thus avoiding potential memleaks and pointless memcpys.

Originally committed as revision 18470 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger
2009-04-12 13:17:37 +00:00
parent 9bf993a5b5
commit 238ef6dadd
11 changed files with 50 additions and 11 deletions

View File

@ -80,6 +80,17 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
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;