Me@178: /* Me@178: * Copyright 2009 OpenSourceCodeStewardshipFoundation.org Me@178: * Licensed under GNU General Public License version 2 Me@178: * Me@178: * Author: seanhalle@yahoo.com Me@178: * Me@178: * Created on November 14, 2009, 9:07 PM Me@178: */ Me@178: Me@178: #include Me@178: #include Me@178: #include Me@178: #include Me@178: Me@178: #include "VMS.h" Me@178: #include "Histogram/Histogram.h" Me@178: Me@178: /*Helper function Me@178: *Insert a newly generated free chunk into the first spot on the free list. Me@178: * The chunk is cast as a MallocProlog, so the various pointers in it are Me@178: * accessed with C's help -- and the size of the prolog is easily added to Me@178: * the pointer when a chunk is returned to the app -- so C handles changes Me@178: * in pointer sizes among machines. Me@178: * Me@178: *The list head is a normal MallocProlog struct -- identified by its Me@178: * prevChunkInFreeList being NULL -- the only one. Me@178: * Me@178: *The end of the list is identified by next chunk being NULL, as usual. Me@178: */ Me@178: void inline Me@178: add_chunk_to_free_list( MallocProlog *chunk, MallocProlog *listHead ) Me@178: { Me@178: chunk->nextChunkInFreeList = listHead->nextChunkInFreeList; Me@178: if( chunk->nextChunkInFreeList != NULL ) //if not last in free list Me@178: chunk->nextChunkInFreeList->prevChunkInFreeList = chunk; Me@178: chunk->prevChunkInFreeList = listHead; Me@178: listHead->nextChunkInFreeList = chunk; Me@178: } Me@178: Me@178: Me@178: /*This is sequential code, meant to only be called from the Master, not from Me@178: * any slave VPs. Me@178: *Search down list, checking size by the nextHigherInMem pointer, to find Me@178: * first chunk bigger than size needed. Me@178: *Shave off the extra and make it into a new free-list element, hook it in Me@178: * then return the address of the found element plus size of prolog. Me@178: * Me@178: *Will find a Me@178: */ Me@178: void *VMS__malloc( size_t sizeRequested ) Me@178: { MallocProlog *foundElem = NULL, *currElem, *newElem; Me@178: ssize_t amountExtra, sizeConsumed,sizeOfFound; Me@178: uint32 foundElemIsTopOfHeap; Me@178: Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: int32 startStamp, endStamp; Me@178: saveLowTimeStampCountInto( startStamp ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: //step up the size to be aligned at 16-byte boundary, prob better ways Me@178: sizeRequested = (sizeRequested + 16) & ~15; Me@178: currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; Me@178: Me@178: while( currElem != NULL ) Me@178: { //check if size of currElem is big enough Me@178: sizeOfFound=(size_t)((uintptr_t)currElem->nextHigherInMem -(uintptr_t)currElem); Me@178: amountExtra = sizeOfFound - sizeRequested - sizeof(MallocProlog); Me@178: if( amountExtra > 0 ) Me@178: { //found it, get out of loop Me@178: foundElem = currElem; Me@178: currElem = NULL; Me@178: } Me@178: else Me@178: currElem = currElem->nextChunkInFreeList; Me@178: } Me@178: Me@178: if( foundElem == NULL ) Me@178: { ERROR("\nmalloc failed\n") Me@178: return (void *)NULL; //indicates malloc failed Me@178: } Me@178: //Using a kludge to identify the element that is the top chunk in the Me@178: // heap -- saving top-of-heap addr in head's nextHigherInMem -- and Me@178: // save addr of start of heap in head's nextLowerInMem Me@178: //Will handle top of Heap specially Me@178: foundElemIsTopOfHeap = foundElem->nextHigherInMem == Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem; Me@178: Me@178: //before shave off and try to insert new elem, remove found elem Me@178: //note, foundElem will never be the head, so always has valid prevChunk Me@178: foundElem->prevChunkInFreeList->nextChunkInFreeList = Me@178: foundElem->nextChunkInFreeList; Me@178: if( foundElem->nextChunkInFreeList != NULL ) Me@178: { foundElem->nextChunkInFreeList->prevChunkInFreeList = Me@178: foundElem->prevChunkInFreeList; Me@178: } Me@178: foundElem->prevChunkInFreeList = NULL;//indicates elem currently allocated Me@178: Me@178: //if enough, turn extra into new elem & insert it Me@178: if( amountExtra > 64 ) Me@178: { //make new elem by adding to addr of curr elem then casting Me@178: sizeConsumed = sizeof(MallocProlog) + sizeRequested; Me@178: newElem = (MallocProlog *)( (uintptr_t)foundElem + sizeConsumed ); Me@178: newElem->nextLowerInMem = foundElem; //This is evil (but why?) Me@178: newElem->nextHigherInMem = foundElem->nextHigherInMem; //This is evil (but why?) Me@178: foundElem->nextHigherInMem = newElem; Me@178: if( ! foundElemIsTopOfHeap ) Me@178: { //there is no next higher for top of heap, so can't write to it Me@178: newElem->nextHigherInMem->nextLowerInMem = newElem; Me@178: } Me@178: add_chunk_to_free_list( newElem, _VMSMasterEnv->freeListHead ); Me@178: } Me@178: else Me@178: { Me@178: sizeConsumed = sizeOfFound; Me@178: } Me@178: _VMSMasterEnv->amtOfOutstandingMem += sizeConsumed; Me@178: Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: saveLowTimeStampCountInto( endStamp ); Me@178: addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->mallocTimeHist ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: //skip over the prolog by adding its size to the pointer return Me@178: return (void*)((uintptr_t)foundElem + sizeof(MallocProlog)); Me@178: } Me@178: Me@178: /*This is sequential code, meant to only be called from the Master, not from Me@178: * any slave VPs. Me@178: *Search down list, checking size by the nextHigherInMem pointer, to find Me@178: * first chunk bigger than size needed. Me@178: *Shave off the extra and make it into a new free-list element, hook it in Me@178: * then return the address of the found element plus size of prolog. Me@178: * Me@178: * The difference to the regular malloc is, that all the allocated chunks are Me@178: * aligned and padded to the size of a CACHE_LINE. Thus creating a new chunk Me@178: * before the aligned chunk. Me@178: */ Me@178: void *VMS__malloc_aligned( size_t sizeRequested ) Me@178: { MallocProlog *foundElem = NULL, *currElem, *newElem; Me@178: ssize_t amountExtra, sizeConsumed,sizeOfFound,prevAmount; Me@178: uint32 foundElemIsTopOfHeap; Me@178: Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: uint32 startStamp, endStamp; Me@178: saveLowTimeStampCountInto( startStamp ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: //step up the size to be multiple of the cache line size Me@178: sizeRequested = (sizeRequested + CACHE_LINE) & ~(CACHE_LINE-1); Me@178: currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; Me@178: Me@178: while( currElem != NULL ) Me@178: { //check if size of currElem is big enough Me@178: sizeOfFound=(size_t)((uintptr_t)currElem->nextHigherInMem -(uintptr_t)currElem); Me@178: amountExtra = sizeOfFound - sizeRequested - sizeof(MallocProlog); Me@178: if( amountExtra > 0 ) Me@178: { Me@178: //look if the found element is already aligned Me@178: if((((uintptr_t)currElem+sizeof(MallocProlog)) & (uintptr_t)(CACHE_LINE-1)) == 0){ Me@178: //found it, get out of loop Me@178: foundElem = currElem; Me@178: break; Me@178: }else{ Me@178: //find first aligned address and check if it's still big enough Me@178: //check also if the space before the aligned address is big enough Me@178: //for a new element Me@178: void *firstAlignedAddr = (void*)(((uintptr_t)currElem + 2*CACHE_LINE) & ~((uintptr_t)(CACHE_LINE-1))); Me@178: prevAmount = (uintptr_t)firstAlignedAddr - (uintptr_t)currElem; Me@178: sizeOfFound=(uintptr_t)currElem->nextHigherInMem -(uintptr_t)firstAlignedAddr + sizeof(MallocProlog); Me@178: amountExtra= sizeOfFound - sizeRequested - sizeof(MallocProlog); Me@178: if(prevAmount > 2*sizeof(MallocProlog) && amountExtra > 0 ){ Me@178: //found suitable element Me@178: //create new previous element and exit loop Me@178: MallocProlog *newAlignedElem = (MallocProlog*)firstAlignedAddr - 1; Me@178: Me@178: //insert new element into free list Me@178: if(currElem->nextChunkInFreeList != NULL) Me@178: currElem->nextChunkInFreeList->prevChunkInFreeList = newAlignedElem; Me@178: newAlignedElem->prevChunkInFreeList = currElem; Me@178: newAlignedElem->nextChunkInFreeList = currElem->nextChunkInFreeList; Me@178: currElem->nextChunkInFreeList = newAlignedElem; Me@178: Me@178: //set higherInMem and lowerInMem Me@178: newAlignedElem->nextHigherInMem = currElem->nextHigherInMem; Me@178: foundElemIsTopOfHeap = currElem->nextHigherInMem == Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem; Me@178: if(!foundElemIsTopOfHeap) Me@178: currElem->nextHigherInMem->nextLowerInMem = newAlignedElem; Me@178: currElem->nextHigherInMem = newAlignedElem; Me@178: newAlignedElem->nextLowerInMem = currElem; Me@178: Me@178: //Found new element leaving loop Me@178: foundElem = newAlignedElem; Me@178: break; Me@178: } Me@178: } Me@178: Me@178: } Me@178: currElem = currElem->nextChunkInFreeList; Me@178: } Me@178: Me@178: if( foundElem == NULL ) Me@178: { ERROR("\nmalloc failed\n") Me@178: return (void *)NULL; //indicates malloc failed Me@178: } Me@178: //Using a kludge to identify the element that is the top chunk in the Me@178: // heap -- saving top-of-heap addr in head's nextHigherInMem -- and Me@178: // save addr of start of heap in head's nextLowerInMem Me@178: //Will handle top of Heap specially Me@178: foundElemIsTopOfHeap = foundElem->nextHigherInMem == Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem; Me@178: Me@178: //before shave off and try to insert new elem, remove found elem Me@178: //note, foundElem will never be the head, so always has valid prevChunk Me@178: foundElem->prevChunkInFreeList->nextChunkInFreeList = Me@178: foundElem->nextChunkInFreeList; Me@178: if( foundElem->nextChunkInFreeList != NULL ) Me@178: { foundElem->nextChunkInFreeList->prevChunkInFreeList = Me@178: foundElem->prevChunkInFreeList; Me@178: } Me@178: foundElem->prevChunkInFreeList = NULL;//indicates elem currently allocated Me@178: Me@178: //if enough, turn extra into new elem & insert it Me@178: if( amountExtra > 64 ) Me@178: { //make new elem by adding to addr of curr elem then casting Me@178: sizeConsumed = sizeof(MallocProlog) + sizeRequested; Me@178: newElem = (MallocProlog *)( (uintptr_t)foundElem + sizeConsumed ); Me@178: newElem->nextHigherInMem = foundElem->nextHigherInMem; Me@178: newElem->nextLowerInMem = foundElem; Me@178: foundElem->nextHigherInMem = newElem; Me@178: Me@178: if( ! foundElemIsTopOfHeap ) Me@178: { //there is no next higher for top of heap, so can't write to it Me@178: newElem->nextHigherInMem->nextLowerInMem = newElem; Me@178: } Me@178: add_chunk_to_free_list( newElem, _VMSMasterEnv->freeListHead ); Me@178: } Me@178: else Me@178: { Me@178: sizeConsumed = sizeOfFound; Me@178: } Me@178: _VMSMasterEnv->amtOfOutstandingMem += sizeConsumed; Me@178: Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: saveLowTimeStampCountInto( endStamp ); Me@178: addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->mallocTimeHist ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: //skip over the prolog by adding its size to the pointer return Me@178: return (void*)((uintptr_t)foundElem + sizeof(MallocProlog)); Me@178: } Me@178: Me@178: Me@178: /*This is sequential code -- only to be called from the Master Me@178: * When free, subtract the size of prolog from pointer, then cast it to a Me@178: * MallocProlog. Then check the nextLower and nextHigher chunks to see if Me@178: * one or both are also free, and coalesce if so, and if neither free, then Me@178: * add this one to free-list. Me@178: */ Me@178: void Me@178: VMS__free( void *ptrToFree ) Me@178: { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; Me@178: size_t sizeOfElem; Me@178: uint32 lowerExistsAndIsFree, higherExistsAndIsFree; Me@178: Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: int32 startStamp, endStamp; Me@178: saveLowTimeStampCountInto( startStamp ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: if( ptrToFree < (void*)_VMSMasterEnv->freeListHead->nextLowerInMem || Me@178: ptrToFree > (void*)_VMSMasterEnv->freeListHead->nextHigherInMem ) Me@178: { //outside the range of data owned by VMS's malloc, so do nothing Me@178: return; Me@178: } Me@178: //subtract size of prolog to get pointer to prolog, then cast Me@178: elemToFree = (MallocProlog *)((uintptr_t)ptrToFree - sizeof(MallocProlog)); Me@178: sizeOfElem =(size_t)((uintptr_t)elemToFree->nextHigherInMem-(uintptr_t)elemToFree); Me@178: Me@178: if( elemToFree->prevChunkInFreeList != NULL ) Me@178: { printf( "error: freeing same element twice!" ); exit(1); Me@178: } Me@178: Me@178: _VMSMasterEnv->amtOfOutstandingMem -= sizeOfElem; Me@178: Me@178: nextLowerElem = elemToFree->nextLowerInMem; Me@178: nextHigherElem = elemToFree->nextHigherInMem; Me@178: Me@178: if( nextHigherElem == NULL ) Me@178: higherExistsAndIsFree = FALSE; Me@178: else //okay exists, now check if in the free-list by checking back ptr Me@178: higherExistsAndIsFree = (nextHigherElem->prevChunkInFreeList != NULL); Me@178: Me@178: if( nextLowerElem == NULL ) Me@178: lowerExistsAndIsFree = FALSE; Me@178: else //okay, it exists, now check if it's free Me@178: lowerExistsAndIsFree = (nextLowerElem->prevChunkInFreeList != NULL); Me@178: Me@178: Me@178: //now, know what exists and what's free Me@178: if( lowerExistsAndIsFree ) Me@178: { if( higherExistsAndIsFree ) Me@178: { //both exist and are free, so coalesce all three Me@178: //First, remove higher from free-list Me@178: nextHigherElem->prevChunkInFreeList->nextChunkInFreeList = Me@178: nextHigherElem->nextChunkInFreeList; Me@178: if( nextHigherElem->nextChunkInFreeList != NULL ) //end-of-list? Me@178: nextHigherElem->nextChunkInFreeList->prevChunkInFreeList = Me@178: nextHigherElem->prevChunkInFreeList; Me@178: //Now, fix-up sequence-in-mem list -- by side-effect, this also Me@178: // changes size of the lower elem, which is still in free-list Me@178: nextLowerElem->nextHigherInMem = nextHigherElem->nextHigherInMem; Me@178: if( nextHigherElem->nextHigherInMem != Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem ) Me@178: nextHigherElem->nextHigherInMem->nextLowerInMem = nextLowerElem; Me@178: //notice didn't do anything to elemToFree -- it simply is no Me@178: // longer reachable from any of the lists. Wonder if could be a Me@178: // security leak because left valid addresses in it, Me@178: // but don't care for now. Me@178: } Me@178: else Me@178: { //lower is the only of the two that exists and is free, Me@178: //In this case, no adjustment to free-list, just change mem-list. Me@178: // By side-effect, changes size of the lower elem Me@178: nextLowerElem->nextHigherInMem = elemToFree->nextHigherInMem; Me@178: if( elemToFree->nextHigherInMem != Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem ) Me@178: elemToFree->nextHigherInMem->nextLowerInMem = nextLowerElem; Me@178: } Me@178: } Me@178: else Me@178: { //lower either doesn't exist or isn't free, so check higher Me@178: if( higherExistsAndIsFree ) Me@178: { //higher exists and is the only of the two free Me@178: //First, in free-list, replace higher elem with the one to free Me@178: elemToFree->nextChunkInFreeList=nextHigherElem->nextChunkInFreeList; Me@178: elemToFree->prevChunkInFreeList=nextHigherElem->prevChunkInFreeList; Me@178: elemToFree->prevChunkInFreeList->nextChunkInFreeList = elemToFree; Me@178: if( elemToFree->nextChunkInFreeList != NULL ) // end-of-list? Me@178: elemToFree->nextChunkInFreeList->prevChunkInFreeList =elemToFree; Me@178: //Now chg mem-list. By side-effect, changes size of elemToFree Me@178: elemToFree->nextHigherInMem = nextHigherElem->nextHigherInMem; Me@178: if( elemToFree->nextHigherInMem != Me@178: _VMSMasterEnv->freeListHead->nextHigherInMem ) Me@178: elemToFree->nextHigherInMem->nextLowerInMem = elemToFree; Me@178: } Me@178: else Me@178: { //neither lower nor higher is availabe to coalesce so add to list Me@178: // this makes prev chunk ptr non-null, which indicates it's free Me@178: elemToFree->nextChunkInFreeList = Me@178: _VMSMasterEnv->freeListHead->nextChunkInFreeList; Me@178: _VMSMasterEnv->freeListHead->nextChunkInFreeList = elemToFree; Me@178: if( elemToFree->nextChunkInFreeList != NULL ) // end-of-list? Me@178: elemToFree->nextChunkInFreeList->prevChunkInFreeList =elemToFree; Me@178: elemToFree->prevChunkInFreeList = _VMSMasterEnv->freeListHead; Me@178: } Me@178: } Me@178: //============================= MEASUREMENT STUFF ======================== Me@178: #ifdef MEAS__TIME_MALLOC Me@178: saveLowTimeStampCountInto( endStamp ); Me@178: addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->freeTimeHist ); Me@178: #endif Me@178: //======================================================================== Me@178: Me@178: } Me@178: Me@178: Me@178: /*Allocates memory from the external system -- higher overhead Me@178: * Me@178: *Because of Linux's malloc throwing bizarre random faults when malloc is Me@178: * used inside a VMS virtual processor, have to pass this as a request and Me@178: * have the core loop do it when it gets around to it -- will look for these Me@178: * chores leftover from the previous animation of masterVP the next time it Me@178: * goes to animate the masterVP -- so it takes two separate masterVP Me@178: * animations, separated by work, to complete an external malloc or Me@178: * external free request. Me@178: * Me@178: *Thinking core loop accepts signals -- just looks if signal-location is Me@178: * empty or not -- Me@178: */ Me@178: void * Me@178: VMS__malloc_in_ext( size_t sizeRequested ) Me@178: { Me@178: /* Me@178: //This is running in the master, so no chance for multiple cores to be Me@178: // competing for the core's flag. Me@178: if( *(_VMSMasterEnv->coreLoopSignalAddr[ 0 ]) != 0 ) Me@178: { //something has already signalled to core loop, so save the signal Me@178: // and look, next time master animated, to see if can send it. Me@178: //Note, the addr to put a signal is in the coreloop's frame, so just Me@178: // checks it each time through -- make it volatile to avoid GCC Me@178: // optimizations -- it's a coreloop local var that only changes Me@178: // after jumping away. The signal includes the addr to send the Me@178: //return to -- even if just empty return completion-signal Me@178: // Me@178: //save the signal in some queue that the master looks at each time Me@178: // it starts up -- one loc says if empty for fast common case -- Me@178: //something like that -- want to hide this inside this call -- but Me@178: // think this has to come as a request -- req handler gives procr Me@178: // back to master loop, which gives it back to req handler at point Me@178: // it sees that core loop has sent return signal. Something like Me@178: // that. Me@178: saveTheSignal Me@178: Me@178: } Me@178: coreSigData->type = malloc; Me@178: coreSigData->sizeToMalloc = sizeRequested; Me@178: coreSigData->locToSignalCompletion = &figureOut; Me@178: _VMSMasterEnv->coreLoopSignals[ 0 ] = coreSigData; Me@178: */ Me@178: //just risk system-stack faults until get this figured out Me@178: return malloc( sizeRequested ); Me@178: } Me@178: Me@178: Me@178: /*Frees memory that was allocated in the external system -- higher overhead Me@178: * Me@178: *As noted in external malloc comment, this is clunky 'cause the free has Me@178: * to be called in the core loop. Me@178: */ Me@178: void Me@178: VMS__free_in_ext( void *ptrToFree ) Me@178: { Me@178: //just risk system-stack faults until get this figured out Me@178: free( ptrToFree ); Me@178: Me@178: //TODO: fix this -- so Me@178: } Me@178: Me@178: Me@178: /*Designed to be called from the main thread outside of VMS, during init Me@178: */ Me@178: MallocProlog * Me@178: VMS_ext__create_free_list() Me@178: { MallocProlog *freeListHead, *firstChunk; Me@178: Me@178: //Note, this is running in the main thread -- all increases in malloc Me@178: // mem and all frees of it must be done in this thread, with the Me@178: // thread's original stack available Me@178: freeListHead = malloc( sizeof(MallocProlog) ); Me@178: firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); Me@178: if( firstChunk == NULL ) {printf("malloc error\n"); exit(1);} Me@178: Me@178: //Touch memory to avoid page faults Me@178: void *ptr,*endPtr; Me@178: endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; Me@178: for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE) Me@178: { Me@178: *(char*)ptr = 0; Me@178: } Me@178: Me@178: freeListHead->prevChunkInFreeList = NULL; Me@178: //Use this addr to free the heap when cleanup Me@178: freeListHead->nextLowerInMem = firstChunk; Me@178: //to identify top-of-heap elem, compare this addr to elem's next higher Me@178: freeListHead->nextHigherInMem = (void*)( (uintptr_t)firstChunk + Me@178: MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE); Me@178: freeListHead->nextChunkInFreeList = firstChunk; Me@178: Me@178: firstChunk->nextChunkInFreeList = NULL; Me@178: firstChunk->prevChunkInFreeList = freeListHead; Me@178: //next Higher has to be set to top of chunk, so can calc size in malloc Me@178: firstChunk->nextHigherInMem = (void*)( (uintptr_t)firstChunk + Me@178: MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE); Me@178: firstChunk->nextLowerInMem = NULL; //identifies as bott of heap Me@178: Me@178: _VMSMasterEnv->amtOfOutstandingMem = 0; //none allocated yet Me@178: Me@178: return freeListHead; Me@178: } Me@178: Me@178: Me@178: /*Designed to be called from the main thread outside of VMS, during cleanup Me@178: */ Me@178: void Me@178: VMS_ext__free_free_list( MallocProlog *freeListHead ) Me@178: { Me@178: //stashed a ptr to the one and only bug chunk malloc'd from OS in the Me@178: // free list head's next lower in mem pointer Me@178: free( freeListHead->nextLowerInMem ); Me@178: Me@178: //don't free the head -- it'll be in an array eventually -- free whole Me@178: // array when all the free lists linked from it have already been freed Me@178: } Me@178: