Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison vmalloc.c @ 126:d0aa5a796fc5
touch memory at start of algorithm to make it comparable
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 07 Sep 2011 14:33:22 +0200 |
| parents | 9b2b9bc2c362 |
| children | 99798e4438a6 1fe7ba1ab81f |
comparison
equal
deleted
inserted
replaced
| 19:d1ee00670148 | 20:535b0f2c7154 |
|---|---|
| 340 //Create first element in lastContainer | 340 //Create first element in lastContainer |
| 341 MallocProlog *firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); | 341 MallocProlog *firstChunk = malloc( MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE ); |
| 342 if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);} | 342 if( firstChunk == NULL ) {printf("Can't allocate initial memory\n"); exit(1);} |
| 343 freeLists->memSpace = firstChunk; | 343 freeLists->memSpace = firstChunk; |
| 344 | 344 |
| 345 //Touch memory to avoid page faults | |
| 346 void *ptr,*endPtr; | |
| 347 endPtr = (void*)firstChunk+MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; | |
| 348 for(ptr = firstChunk; ptr < endPtr; ptr+=PAGE_SIZE) | |
| 349 { | |
| 350 *(char*)ptr = 0; | |
| 351 } | |
| 352 | |
| 345 firstChunk->nextLowerInMem = NULL; | 353 firstChunk->nextLowerInMem = NULL; |
| 346 firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + | 354 firstChunk->nextHigherInMem = (MallocProlog*)((uintptr_t)firstChunk + |
| 347 MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog*)); | 355 MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE - sizeof(MallocProlog*)); |
| 348 firstChunk->nextChunkInFreeList = NULL; | 356 firstChunk->nextChunkInFreeList = NULL; |
| 349 //previous element in the queue is the container | 357 //previous element in the queue is the container |
