diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-03-22 11:00:51 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-03-22 11:00:51 +0000 |
commit | 4e39ab4c973d935fdae40ddec99b40cfc8ac3632 (patch) | |
tree | bb093e1479be2e8e1c32b0defe22f64a17c11f92 | |
parent | 8d1f2ba5e1f411836a7470f1b70676d2fe870303 (diff) | |
download | ffmpeg-4e39ab4c973d935fdae40ddec99b40cfc8ac3632.tar.gz |
1000l in av_mallocz_static()
less overallocation in av_fast_realloc() for small arrays
Originally committed as revision 2913 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index df469300d8..ba4387c1c8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; } |