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:
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user