win: fix building on MinGW

MinGW does not have LOCALE_INVARIANT/_malloca/_freea/wmemcpy_s present on the system.

My building environment:

gcc version 4.8.1 (GCC)
GNU gdb (GDB) 7.6.1
GNU ld (GNU Binutils) 2.24
GNU windres (GNU Binutils) 2.24
GNU dlltool (GNU Binutils) 2.24
GNU Make 3.82.90
I don't really like the idea of allocating memory in one place or in another depending on how the library was compiled. I'd rather always fallback to malloc/free.