dyld-519.2.1.tar.gz
[apple/dyld.git] / testing / test-cases / interpose-malloc.dtest / interposer.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <mach-o/dyld-interposing.h>
4
5
6 char buffer[100000];
7 char* p = buffer;
8
9 void* mymalloc(size_t size)
10 {
11 // bump ptr allocate twice the size and fill second half with '#'
12 char* result = p;
13 p += size;
14 memset(p, '#', size);
15 p += size;
16 p = (char*)(((long)p + 15) & (-16)); // 16-byte align next malloc
17 return result;
18 }
19
20 void myfree(void* p)
21 {
22 }
23
24 DYLD_INTERPOSE(mymalloc, malloc)
25 DYLD_INTERPOSE(myfree, free)