Commit 7a8ebadb authored by michael's avatar michael

1000l in av_mallocz_static()

less overallocation in av_fast_realloc() for small arrays


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2913 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3ea6fb43
......@@ -60,7 +60,7 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
if(min_size < *size)
return ptr;
*size= min_size + 10*1024;
*size= 17*min_size/16 + 32;
return av_realloc(ptr, *size);
}
......@@ -69,7 +69,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
static unsigned int last_static = 0;
static unsigned int allocated_static = 0;
static void** array_static = NULL;
static const unsigned int grow_static = 64; // ^2
/**
* allocation of static arrays - do not use for normal allocation.
......@@ -79,7 +78,7 @@ void *av_mallocz_static(unsigned int size)
void *ptr = av_mallocz(size);
if(ptr){
array_static =av_fast_realloc(array_static, &allocated_static, last_static+1);
array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
array_static[last_static++] = ptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment