void * ilu_full_malloc(ilu_cardinal size, const char *file, int line) { void *ans; FreerList fl; ans = REAL_MALLOC((SIZE_T) size); ILU_NOTE(MALLOC_DEBUG, ("ilu_malloc(%lu=0x%lx)@%s:%d => %p\n", size, size, file, line, ans)); if ((ans != NIL) || (size == 0)) return ans; for (fl = freers; fl != NIL; fl = fl->next) { ILU_NOTE(MALLOC_DEBUG, ("ilu_malloc: trying freer %p\n", fl->free)); fl->free(size); ans = REAL_MALLOC((SIZE_T) size); ILU_NOTE(MALLOC_DEBUG, ("ilu_malloc(%lu=0x%lx)@%s:%d finally => %p\n", size, size, file, line, ans)); if (ans != NIL) return ans; } ILU_NOTE(MALLOC_DEBUG, ("ilu_malloc(%lu=0x%lx)@%s:%d fails.\n", size, size, file, line)); return NIL; }
// This is a fake implementation of malloc that layers on top of the // native platforms malloc routine (ideally using weak symbols). What // it does if given a specail size request it returns a fake address // result, otherwise it uses the underlying malloc. void* malloc(size_t aSize) { if (aSize == LD_PRELOAD_TEST_MALLOC_SIZE) { return (void*) LD_PRELOAD_TEST_VALUE; } else { return REAL_MALLOC(aSize); } }