comparison vmalloc.c @ 138:38c1070e2c92

closing branch test_without_inline
author Merten Sach <msach@mailbox.tu-berlin.de>
date Mon, 19 Sep 2011 14:17:06 +0200
parents 7b799a46cc87
children
comparison
equal deleted inserted replaced
3:de4afbd8fc90 4:deef8b9a84fe
22 *The list head is a normal MallocProlog struct -- identified by its 22 *The list head is a normal MallocProlog struct -- identified by its
23 * prevChunkInFreeList being NULL -- the only one. 23 * prevChunkInFreeList being NULL -- the only one.
24 * 24 *
25 *The end of the list is identified by next chunk being NULL, as usual. 25 *The end of the list is identified by next chunk being NULL, as usual.
26 */ 26 */
27 void inline 27 void
28 add_chunk_to_free_list( MallocProlog *chunk, MallocProlog *listHead ) 28 add_chunk_to_free_list( MallocProlog *chunk, MallocProlog *listHead )
29 { 29 {
30 chunk->nextChunkInFreeList = listHead->nextChunkInFreeList; 30 chunk->nextChunkInFreeList = listHead->nextChunkInFreeList;
31 if( chunk->nextChunkInFreeList != NULL ) //if not last in free list 31 if( chunk->nextChunkInFreeList != NULL ) //if not last in free list
32 chunk->nextChunkInFreeList->prevChunkInFreeList = chunk; 32 chunk->nextChunkInFreeList->prevChunkInFreeList = chunk;
48 VMS__malloc( int32 sizeRequested ) 48 VMS__malloc( int32 sizeRequested )
49 { MallocProlog *foundElem = NULL, *currElem, *newElem; 49 { MallocProlog *foundElem = NULL, *currElem, *newElem;
50 int32 amountExtra, foundElemIsTopOfHeap, sizeConsumed,sizeOfFound; 50 int32 amountExtra, foundElemIsTopOfHeap, sizeConsumed,sizeOfFound;
51 51
52 //step up the size to be aligned at 16-byte boundary, prob better ways 52 //step up the size to be aligned at 16-byte boundary, prob better ways
53 sizeRequested = ((sizeRequested + 16) >> 4) << 4; 53 sizeRequested = ((sizeRequested + 15) >> 4) << 4;
54 currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; 54 currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList;
55 55
56 while( currElem != NULL ) 56 while( currElem != NULL )
57 { //check if size of currElem is big enough 57 { //check if size of currElem is big enough
58 sizeOfFound=(int32)((char*)currElem->nextHigherInMem -(char*)currElem); 58 sizeOfFound=(int32)((char*)currElem->nextHigherInMem -(char*)currElem);