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