Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison vmalloc.c @ 125:9b2b9bc2c362
code cleaning
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 07 Sep 2011 14:28:20 +0200 |
| parents | e29bb31df078 |
| children | d0aa5a796fc5 |
comparison
equal
deleted
inserted
replaced
| 18:4777e7b35a35 | 19:d1ee00670148 |
|---|---|
| 94 if(chunk->nextChunkInFreeList) | 94 if(chunk->nextChunkInFreeList) |
| 95 chunk->nextChunkInFreeList->prevChunkInFreeList = chunk->prevChunkInFreeList; | 95 chunk->nextChunkInFreeList->prevChunkInFreeList = chunk->prevChunkInFreeList; |
| 96 | 96 |
| 97 //The last element in the list points to the container. If the container points | 97 //The last element in the list points to the container. If the container points |
| 98 //to NULL the container is empty | 98 //to NULL the container is empty |
| 99 if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= 160); | 99 if(*((void**)(chunk->prevChunkInFreeList)) == NULL && getChunkSize(chunk) >= BIG_LOWER_BOUND); |
| 100 { | 100 { |
| 101 //Find the approppiate container because we do not know it | 101 //Find the approppiate container because we do not know it |
| 102 uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; | 102 uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; |
| 103 if(containerIdx < (uint32)64) | 103 if(containerIdx < (uint32)64) |
| 104 freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); | 104 freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); |
| 181 | 181 |
| 182 foundChunk = removeChunk(freeLists, containerIdx); | 182 foundChunk = removeChunk(freeLists, containerIdx); |
| 183 size_t chunkSize = getChunkSize(foundChunk); | 183 size_t chunkSize = getChunkSize(foundChunk); |
| 184 | 184 |
| 185 //If the new chunk is larger than the requested size: split | 185 //If the new chunk is larger than the requested size: split |
| 186 if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + 160) | 186 if(chunkSize > sizeRequested + 2 * sizeof(MallocProlog) + BIG_LOWER_BOUND) |
| 187 { | 187 { |
| 188 MallocProlog *newChunk = divideChunk(foundChunk,sizeRequested); | 188 MallocProlog *newChunk = divideChunk(foundChunk,sizeRequested); |
| 189 containerIdx = getContainer(getChunkSize(foundChunk)) - 1; | 189 containerIdx = getContainer(getChunkSize(foundChunk)) - 1; |
| 190 insertChunk(foundChunk,&freeLists->bigChunks[containerIdx]); | 190 insertChunk(foundChunk,&freeLists->bigChunks[containerIdx]); |
| 191 if(containerIdx < 64) | 191 if(containerIdx < 64) |
| 288 chunkToFree = mergeChunks(chunkToFree, chunkToFree->nextHigherInMem); | 288 chunkToFree = mergeChunks(chunkToFree, chunkToFree->nextHigherInMem); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 size_t chunkSize = getChunkSize(chunkToFree); | 292 size_t chunkSize = getChunkSize(chunkToFree); |
| 293 if(chunkSize < 160) | 293 if(chunkSize < BIG_LOWER_BOUND) |
| 294 { | 294 { |
| 295 containerIdx = (chunkSize/SMALL_CHUNK_SIZE)-1; | 295 containerIdx = (chunkSize/SMALL_CHUNK_SIZE)-1; |
| 296 if(containerIdx > 3) | 296 if(containerIdx > SMALL_CHUNK_COUNT-1) |
| 297 containerIdx = 3; | 297 containerIdx = SMALL_CHUNK_COUNT-1; |
| 298 insertChunk(chunkToFree, &freeLists->smallChunks[containerIdx]); | 298 insertChunk(chunkToFree, &freeLists->smallChunks[containerIdx]); |
| 299 } | 299 } |
| 300 else | 300 else |
| 301 { | 301 { |
| 302 containerIdx = getContainer(getChunkSize(chunkToFree)) - 1; | 302 containerIdx = getContainer(getChunkSize(chunkToFree)) - 1; |
