MCPcopy Create free account
hub / github.com/DFHack/dfhack / alloc

Function alloc

depends/sizecheck/sizecheck.cpp:38–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36#endif
37
38void* alloc(size_t n) {
39 if (!initialized) {
40 init();
41 }
42 void* addr;
43 if (posix_memalign(&addr, 32, n + 16) != 0) {
44 return addr;
45 }
46 memset(addr, 0, 16);
47 *(size_t*)addr = n;
48 *(uint32_t*)((uint8_t*)addr + 8) = MAGIC;
49 if (perturb > 0) {
50 memset((uint8_t*)addr + 16, ~(perturb & 0xff), n);
51 }
52 return (uint8_t*)addr + 16;
53}
54
55void dealloc(void* addr) {
56 if (!initialized) {

Callers 1

operator newFunction · 0.85

Calls 2

posix_memalignFunction · 0.85
initFunction · 0.70

Tested by

no test coverage detected