Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison vmalloc.c @ 65:13b22ffb8a2f
Nov 14 vers -- Added measurement of Plugin, malloc, & master lock, + vutilities
| author | Me |
|---|---|
| date | Sun, 14 Nov 2010 11:17:52 -0800 |
| parents | 7b799a46cc87 |
| children | bf08108405cc 9c3107044f86 |
comparison
equal
deleted
inserted
replaced
| 3:de4afbd8fc90 | 5:b9bccc28ac9e |
|---|---|
| 47 void * | 47 void * |
| 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 //============================= MEASUREMENT STUFF ======================== | |
| 53 #ifdef MEAS__TIME_MALLOC | |
| 54 int32 startStamp, endStamp; | |
| 55 saveLowTimeStampCountInto( startStamp ); | |
| 56 #endif | |
| 57 //======================================================================== | |
| 58 | |
| 52 //step up the size to be aligned at 16-byte boundary, prob better ways | 59 //step up the size to be aligned at 16-byte boundary, prob better ways |
| 53 sizeRequested = ((sizeRequested + 16) >> 4) << 4; | 60 sizeRequested = ((sizeRequested + 16) >> 4) << 4; |
| 54 currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; | 61 currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; |
| 55 | 62 |
| 56 while( currElem != NULL ) | 63 while( currElem != NULL ) |
| 106 { | 113 { |
| 107 sizeConsumed = sizeOfFound; | 114 sizeConsumed = sizeOfFound; |
| 108 } | 115 } |
| 109 _VMSMasterEnv->amtOfOutstandingMem += sizeConsumed; | 116 _VMSMasterEnv->amtOfOutstandingMem += sizeConsumed; |
| 110 | 117 |
| 118 //============================= MEASUREMENT STUFF ======================== | |
| 119 #ifdef MEAS__TIME_MALLOC | |
| 120 saveLowTimeStampCountInto( endStamp ); | |
| 121 addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->mallocTimeHist ); | |
| 122 #endif | |
| 123 //======================================================================== | |
| 124 | |
| 111 //skip over the prolog by adding its size to the pointer return | 125 //skip over the prolog by adding its size to the pointer return |
| 112 return (void *)((char *)foundElem + sizeof(MallocProlog)); | 126 return (void *)((char *)foundElem + sizeof(MallocProlog)); |
| 113 } | 127 } |
| 114 | 128 |
| 115 | 129 |
| 121 */ | 135 */ |
| 122 void | 136 void |
| 123 VMS__free( void *ptrToFree ) | 137 VMS__free( void *ptrToFree ) |
| 124 { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; | 138 { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; |
| 125 int32 lowerExistsAndIsFree, higherExistsAndIsFree, sizeOfElem; | 139 int32 lowerExistsAndIsFree, higherExistsAndIsFree, sizeOfElem; |
| 140 | |
| 141 //============================= MEASUREMENT STUFF ======================== | |
| 142 #ifdef MEAS__TIME_MALLOC | |
| 143 int32 startStamp, endStamp; | |
| 144 saveLowTimeStampCountInto( startStamp ); | |
| 145 #endif | |
| 146 //======================================================================== | |
| 126 | 147 |
| 127 if( ptrToFree < (void*)_VMSMasterEnv->freeListHead->nextLowerInMem || | 148 if( ptrToFree < (void*)_VMSMasterEnv->freeListHead->nextLowerInMem || |
| 128 ptrToFree > (void*)_VMSMasterEnv->freeListHead->nextHigherInMem ) | 149 ptrToFree > (void*)_VMSMasterEnv->freeListHead->nextHigherInMem ) |
| 129 { //outside the range of data owned by VMS's malloc, so do nothing | 150 { //outside the range of data owned by VMS's malloc, so do nothing |
| 130 return; | 151 return; |
| 209 if( elemToFree->nextChunkInFreeList != NULL ) // end-of-list? | 230 if( elemToFree->nextChunkInFreeList != NULL ) // end-of-list? |
| 210 elemToFree->nextChunkInFreeList->prevChunkInFreeList =elemToFree; | 231 elemToFree->nextChunkInFreeList->prevChunkInFreeList =elemToFree; |
| 211 elemToFree->prevChunkInFreeList = _VMSMasterEnv->freeListHead; | 232 elemToFree->prevChunkInFreeList = _VMSMasterEnv->freeListHead; |
| 212 } | 233 } |
| 213 } | 234 } |
| 235 //============================= MEASUREMENT STUFF ======================== | |
| 236 #ifdef MEAS__TIME_MALLOC | |
| 237 saveLowTimeStampCountInto( endStamp ); | |
| 238 addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->freeTimeHist ); | |
| 239 #endif | |
| 240 //======================================================================== | |
| 214 | 241 |
| 215 } | 242 } |
| 216 | 243 |
| 217 | 244 |
| 218 /*Allocates memory from the external system -- higher overhead | 245 /*Allocates memory from the external system -- higher overhead |
