# HG changeset patch # User Merten Sach # Date 1315398500 -7200 # Node ID 9b2b9bc2c362bf0019f3ba6a4842b6f38505e7cf # Parent e29bb31df07859bb7f0b1d7dfda0ec208f640e60 code cleaning diff -r e29bb31df078 -r 9b2b9bc2c362 vmalloc.c --- a/vmalloc.c Tue Aug 30 17:45:14 2011 +0200 +++ b/vmalloc.c Wed Sep 07 14:28:20 2011 +0200 @@ -96,7 +96,7 @@ //The last element in the list points to the container. If the container points //to NULL the container is empty - if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= 160); + if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= BIG_LOWER_BOUND); { //Find the approppiate container because we do not know it uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; @@ -183,7 +183,7 @@ size_t chunkSize = getChunkSize(foundChunk); //If the new chunk is larger than the requested size: split - if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + 160) + if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + BIG_LOWER_BOUND) { MallocProlog *newChunk = divideChunk(foundChunk,sizeRequested); containerIdx = getContainer(getChunkSize(foundChunk)) - 1; @@ -290,11 +290,11 @@ } size_t chunkSize = getChunkSize(chunkToFree); - if(chunkSize < 160) + if(chunkSize < BIG_LOWER_BOUND) { containerIdx = (chunkSize/SMALL_CHUNK_SIZE)-1; - if(containerIdx > 3) - containerIdx = 3; + if(containerIdx > SMALL_CHUNK_COUNT-1) + containerIdx = SMALL_CHUNK_COUNT-1; insertChunk(chunkToFree, &freeLists->smallChunks[containerIdx]); } else diff -r e29bb31df078 -r 9b2b9bc2c362 vmalloc.h --- a/vmalloc.h Tue Aug 30 17:45:14 2011 +0200 +++ b/vmalloc.h Wed Sep 07 14:28:20 2011 +0200 @@ -16,10 +16,8 @@ #define SMALL_CHUNK_SIZE 32 #define SMALL_CHUNK_COUNT 4 -#define LOWER_BOUND 128 -#define CHUNK_INCREASE_RATE 1.25 -#define MAX_SMALL_CHUNKS 20 -#define SMALL_CHUNKS_ALLOCATION 5 +#define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks +#define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks #define LOG54 0.3219280948873623 #define LOG128 7