added stdio.h to avoid warning about printf
Allow switching malloc/realloc/free