| 142 | |
| 143 | |
| 144 | SimpleHeap *SimpleHeap::CreateBlock() |
| 145 | // Added for v1.0.40.04 to try to solve the fact that some functions such as GetRawInputDeviceList() |
| 146 | // will sometimes fail if passed memory from SimpleHeap. Although this change didn't actually solve |
| 147 | // the issue (it turned out to be a 32-bit alignment issue), using malloc() appears to save memory |
| 148 | // (compared to using "new" on a class that contains a large buffer such as "char mBlock[BLOCK_SIZE]"). |
| 149 | // In a 200 KB script, it saves 8 KB of VM Size as shown by Task Manager. |
| 150 | { |
| 151 | SimpleHeap *block; |
| 152 | if ( !(block = new SimpleHeap) ) |
| 153 | return NULL; |
| 154 | // The new block's mFreeMarker starts off pointing to the first byte in the new block: |
| 155 | if ( !(block->mBlock = block->mFreeMarker = (char *)malloc(BLOCK_SIZE)) ) |
| 156 | { |
| 157 | delete block; |
| 158 | return NULL; |
| 159 | } |
| 160 | // Since above didn't return, block was successfully created: |
| 161 | block->mSpaceAvailable = BLOCK_SIZE; |
| 162 | sLast = block; // Constructing a new block always results in it becoming the current block. |
| 163 | ++sBlockCount; |
| 164 | return block; |
| 165 | } |
| 166 | |
| 167 | |
| 168 |
nothing calls this directly
no outgoing calls
no test coverage detected