Fixed problem of "strdup" not found in mingw-w64

Modified api.c to work with mingw-w64 on windows.