21 lines
536 B
C
21 lines
536 B
C
#include <assert.h>
|
|
#include <memory.h>
|
|
#include <stdlib.h>
|
|
|
|
int memory_sweep(const uintptr_t start, const uintptr_t end) {
|
|
assert_msg(start < end, "Start needs to be before end.");
|
|
uintptr_t sweeper = start;
|
|
|
|
while (sweeper < end) {
|
|
*(uint64_t *)sweeper = 0xFAFAFAFABCBCBCBC;
|
|
sweeper += sizeof(uint64_t);
|
|
}
|
|
|
|
sweeper -= sizeof(uint64_t);
|
|
while (sweeper != start) {
|
|
assert(*(uint64_t *)sweeper == 0xFAFAFAFABCBCBCBC);
|
|
sweeper -= sizeof(uint64_t);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|