| 235 | } |
| 236 | |
| 237 | void* fxCheckChunk(txMachine* the, txChunk* chunk, txSize size, txSize offset) |
| 238 | { |
| 239 | if (chunk) { |
| 240 | txByte* data = (txByte*)chunk; |
| 241 | #if mxNoChunks |
| 242 | chunk->size = size; |
| 243 | the->currentChunksSize += size; |
| 244 | #else |
| 245 | txSize capacity = (txSize)(chunk->temporary - data); |
| 246 | #ifdef mxSnapshot |
| 247 | #if INTPTR_MAX == INT64_MAX |
| 248 | chunk->dummy = 0; |
| 249 | #endif |
| 250 | #ifdef mxSnapshotRandomInit |
| 251 | arc4random_buf(data + sizeof(txChunk), offset); |
| 252 | #endif |
| 253 | #endif |
| 254 | offset += sizeof(txChunk); |
| 255 | c_memset(data + offset, 0, capacity - offset); |
| 256 | chunk->size = size; |
| 257 | the->currentChunksSize += capacity; |
| 258 | #endif |
| 259 | if (the->peakChunksSize < the->currentChunksSize) |
| 260 | the->peakChunksSize = the->currentChunksSize; |
| 261 | return data + sizeof(txChunk); |
| 262 | } |
| 263 | fxReport(the, "# Chunk allocation: failed for %ld bytes\n", (long)size); |
| 264 | fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT); |
| 265 | return C_NULL; |
| 266 | } |
| 267 | |
| 268 | #if defined(__clang__) || defined (__GNUC__) |
| 269 | __attribute__((no_sanitize_address)) |
no test coverage detected