comparison vmalloc.c @ 142:1fe7ba1ab81f

bugfixes and typos
author Merten Sach <msach@mailbox.tu-berlin.de>
date Wed, 21 Sep 2011 12:35:11 +0200
parents d0aa5a796fc5
children c3f458403cd6
comparison
equal deleted inserted replaced
20:535b0f2c7154 28:addbb180c0d4
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) >= BIG_LOWER_BOUND); 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);
350 *(char*)ptr = 0; 350 *(char*)ptr = 0;
351 } 351 }
352 352
353 firstChunk->nextLowerInMem = NULL; 353 firstChunk->nextLowerInMem = NULL;
354 firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + 354 firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk +
355 MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog*)); 355 MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog));
356 firstChunk->nextChunkInFreeList = NULL; 356 firstChunk->nextChunkInFreeList = NULL;
357 //previous element in the queue is the container 357 //previous element in the queue is the container
358 firstChunk->prevChunkInFreeList = &freeLists->bigChunks[container-2]; 358 firstChunk->prevChunkInFreeList = &freeLists->bigChunks[container-2];
359 359
360 freeLists->bigChunks[container-2] = firstChunk; 360 freeLists->bigChunks[container-2] = firstChunk;
361 //Insert into bit search list 361 //Insert into bit search list
362 if(container <= 65) 362 if(container <= 65)
363 freeLists->bigChunksSearchVector[0] |= ((uint64)1 << (container-2)); 363 {
364 freeLists->bigChunksSearchVector[0] = ((uint64)1 << (container-2));
365 freeLists->bigChunksSearchVector[1] = 0;
366 }
364 else 367 else
365 freeLists->bigChunksSearchVector[1] |= ((uint64)1 << (container-66)); 368 {
369 freeLists->bigChunksSearchVector[0] = 0;
370 freeLists->bigChunksSearchVector[1] = ((uint64)1 << (container-66));
371 }
366 372
367 //Create dummy chunk to mark the top of stack this is of course 373 //Create dummy chunk to mark the top of stack this is of course
368 //never freed 374 //never freed
369 MallocProlog *dummyChunk = firstChunk->nextHigherInMem; 375 MallocProlog *dummyChunk = firstChunk->nextHigherInMem;
370 dummyChunk->nextHigherInMem = dummyChunk+1; 376 dummyChunk->nextHigherInMem = dummyChunk+1;