This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uintptr_t base; | |
const uintptr_t height = 100000000; | |
std::mt19937 rng; | |
[[gnu::constructor]] void init_malloc() { | |
base = (uintptr_t) sbrk(height); | |
} | |
void* malloc(size_t) { // parameter ignored, we don't need it | |
return (void*)(base + rng() % height); // odds of any collision is like, low | |
} | |
void free(void*) {} // no-op |