Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison vmalloc.c @ 203:caa8512f7bdc
changed __brch__ contents for update naming scheme
| author | Me@portablequad |
|---|---|
| date | Mon, 13 Feb 2012 09:23:27 -0800 |
| parents | c1784868dcea |
| children | cb888346c3e0 |
comparison
equal
deleted
inserted
replaced
| 32:ee73e3d5f24d | 34:767037c601c8 |
|---|---|
| 11 #include <inttypes.h> | 11 #include <inttypes.h> |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 | 14 |
| 15 #include "VMS.h" | 15 #include "VMS.h" |
| 16 #include "Histogram/Histogram.h" | 16 #include "../../C_Libraries/Histogram/Histogram.h" |
| 17 | 17 |
| 18 /*Helper function | 18 /*Helper function |
| 19 *Insert a newly generated free chunk into the first spot on the free list. | 19 *Insert a newly generated free chunk into the first spot on the free list. |
| 20 * The chunk is cast as a MallocProlog, so the various pointers in it are | 20 * The chunk is cast as a MallocProlog, so the various pointers in it are |
| 21 * accessed with C's help -- and the size of the prolog is easily added to | 21 * accessed with C's help -- and the size of the prolog is easily added to |
| 43 *Search down list, checking size by the nextHigherInMem pointer, to find | 43 *Search down list, checking size by the nextHigherInMem pointer, to find |
| 44 * first chunk bigger than size needed. | 44 * first chunk bigger than size needed. |
| 45 *Shave off the extra and make it into a new free-list element, hook it in | 45 *Shave off the extra and make it into a new free-list element, hook it in |
| 46 * then return the address of the found element plus size of prolog. | 46 * then return the address of the found element plus size of prolog. |
| 47 * | 47 * |
| 48 *Will find a | 48 */ |
| 49 */ | 49 void *VMS_int__malloc( size_t sizeRequested ) |
| 50 void *VMS__malloc( size_t sizeRequested ) | |
| 51 { MallocProlog *foundElem = NULL, *currElem, *newElem; | 50 { MallocProlog *foundElem = NULL, *currElem, *newElem; |
| 52 ssize_t amountExtra, sizeConsumed,sizeOfFound; | 51 ssize_t amountExtra, sizeConsumed,sizeOfFound; |
| 53 uint32 foundElemIsTopOfHeap; | 52 uint32 foundElemIsTopOfHeap; |
| 54 | 53 |
| 55 //============================= MEASUREMENT STUFF ======================== | 54 //============================= MEASUREMENT STUFF ======================== |
| 137 * | 136 * |
| 138 * The difference to the regular malloc is, that all the allocated chunks are | 137 * The difference to the regular malloc is, that all the allocated chunks are |
| 139 * aligned and padded to the size of a CACHE_LINE. Thus creating a new chunk | 138 * aligned and padded to the size of a CACHE_LINE. Thus creating a new chunk |
| 140 * before the aligned chunk. | 139 * before the aligned chunk. |
| 141 */ | 140 */ |
| 142 void *VMS__malloc_aligned( size_t sizeRequested ) | 141 void *VMS_int__malloc_aligned( size_t sizeRequested ) |
| 143 { MallocProlog *foundElem = NULL, *currElem, *newElem; | 142 { MallocProlog *foundElem = NULL, *currElem, *newElem; |
| 144 ssize_t amountExtra, sizeConsumed,sizeOfFound,prevAmount; | 143 ssize_t amountExtra, sizeConsumed,sizeOfFound,prevAmount; |
| 145 uint32 foundElemIsTopOfHeap; | 144 uint32 foundElemIsTopOfHeap; |
| 146 | 145 |
| 147 //============================= MEASUREMENT STUFF ======================== | 146 //============================= MEASUREMENT STUFF ======================== |
| 264 * MallocProlog. Then check the nextLower and nextHigher chunks to see if | 263 * MallocProlog. Then check the nextLower and nextHigher chunks to see if |
| 265 * one or both are also free, and coalesce if so, and if neither free, then | 264 * one or both are also free, and coalesce if so, and if neither free, then |
| 266 * add this one to free-list. | 265 * add this one to free-list. |
| 267 */ | 266 */ |
| 268 void | 267 void |
| 269 VMS__free( void *ptrToFree ) | 268 VMS_int__free( void *ptrToFree ) |
| 270 { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; | 269 { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; |
| 271 size_t sizeOfElem; | 270 size_t sizeOfElem; |
| 272 uint32 lowerExistsAndIsFree, higherExistsAndIsFree; | 271 uint32 lowerExistsAndIsFree, higherExistsAndIsFree; |
| 273 | 272 |
| 274 //============================= MEASUREMENT STUFF ======================== | 273 //============================= MEASUREMENT STUFF ======================== |
