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
Why downgrade to the lowest common denominator? Here is the implementation MinGW-w64 uses: https://github.com/Alexpux/Mingw-w64/blob/master/mingw-w64-crt/secapi/wmemcpy_s.c#L36