#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern void* myalloc1(size_t);
extern void* myalloc2(size_t);
int main()
{
printf("[BEGIN] interpose-malloc\n");
char* p1 = malloc(10);
if ( strncmp(p1+10, "##########", 10) != 0 ) {
printf("[FAIL] interpose-malloc malloc() from main executable not interposed\n");
return 0;
}
void* p2 = myalloc1(6);
if ( strncmp(p2+6, "######", 6) != 0 ) {
printf("[FAIL] interpose-malloc myalloc1() from libfoo.dylib not interposed\n");
return 0;
}
void* p3 = myalloc2(10);
if ( strncmp(p3+10, "##########", 10) != 0 ) {
printf("[FAIL] interpose-malloc myalloc2() from libfoo.dylib not interposed\n");
return 0;
}
void* p4 = strdup("hello");
if ( strncmp(p4+6, "#######", 6) != 0 ) {
printf("[FAIL] interpose-malloc malloc() from strdup not interposed\n");
return 0;
}
printf("[PASS] interpose-malloc\n");
return 0;
}