| 443 | // --------------------------------------------------------------------------------------------------------------------------------- |
| 444 | |
| 445 | static void wipeWithPattern(sAllocUnit *allocUnit, unsigned long pattern, const unsigned int originalReportedSize = 0) |
| 446 | { |
| 447 | // For a serious test run, we use wipes of random a random value. However, if this causes a crash, we don't want it to |
| 448 | // crash in a differnt place each time, so we specifically DO NOT call srand. If, by chance your program calls srand(), |
| 449 | // you may wish to disable that when running with a random wipe test. This will make any crashes more consistent so they |
| 450 | // can be tracked down easier. |
| 451 | |
| 452 | if (randomWipe) |
| 453 | { |
| 454 | pattern = ((rand() & 0xff) << 24) | ((rand() & 0xff) << 16) | ((rand() & 0xff) << 8) | (rand() & 0xff); |
| 455 | } |
| 456 | |
| 457 | // -DOC- We should wipe with 0's if we're not in debug mode, so we can help hide bugs if possible when we release the |
| 458 | // product. So uncomment the following line for releases. |
| 459 | // |
| 460 | // Note that the "alwaysWipeAll" should be turned on for this to have effect, otherwise it won't do much good. But we'll |
| 461 | // leave it this way (as an option) because this does slow things down. |
| 462 | // pattern = 0; |
| 463 | |
| 464 | // This part of the operation is optional |
| 465 | |
| 466 | if (alwaysWipeAll && allocUnit->reportedSize > originalReportedSize) |
| 467 | { |
| 468 | // Fill the bulk |
| 469 | |
| 470 | long *lptr = reinterpret_cast<long *>(reinterpret_cast<char *>(allocUnit->reportedAddress) + originalReportedSize); |
| 471 | int length = static_cast<int>(allocUnit->reportedSize - originalReportedSize); |
| 472 | int i; |
| 473 | for (i = 0; i < (length >> 2); i++, lptr++) |
| 474 | { |
| 475 | *lptr = pattern; |
| 476 | } |
| 477 | |
| 478 | // Fill the remainder |
| 479 | |
| 480 | unsigned int shiftCount = 0; |
| 481 | char *cptr = reinterpret_cast<char *>(lptr); |
| 482 | for (i = 0; i < (length & 0x3); i++, cptr++, shiftCount += 8) |
| 483 | { |
| 484 | *cptr = static_cast<char>((pattern & (0xff << shiftCount)) >> shiftCount); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // Write in the prefix/postfix bytes |
| 489 | |
| 490 | long *pre = reinterpret_cast<long *>(allocUnit->actualAddress); |
| 491 | long *post = reinterpret_cast<long *>(reinterpret_cast<char *>(allocUnit->actualAddress) + allocUnit->actualSize - paddingSize * sizeof(long)); |
| 492 | for (unsigned int i = 0; i < paddingSize; i++, pre++, post++) |
| 493 | { |
| 494 | *pre = prefixPattern; |
| 495 | *post = postfixPattern; |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | // --------------------------------------------------------------------------------------------------------------------------------- |
| 500 |
no outgoing calls
no test coverage detected