From cf021f32e62370b7f9c8249a6c600cbe48e849c7 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Mon, 18 May 2020 11:57:34 +0200 Subject: MinGW now has _mktemp_s, use overload with size parameter MSVC also used the custom implementation, since the function isn't a macro and therefore #ifndef _mktemp_s didn't work as intended. --- src/test.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/test.cc b/src/test.cc index 8ba2297..021005e 100644 --- a/src/test.cc +++ b/src/test.cc @@ -24,6 +24,7 @@ #include #ifdef _WIN32 #include +#include #else #include #endif @@ -45,19 +46,9 @@ extern "C" { namespace { #ifdef _WIN32 -#ifndef _mktemp_s -/// mingw has no mktemp. Implement one with the same type as the one -/// found in the Windows API. -int _mktemp_s(char* templ) { - char* ofs = strchr(templ, 'X'); - sprintf(ofs, "%d", rand() % 1000000); - return 0; -} -#endif - /// Windows has no mkdtemp. Implement it in terms of _mktemp_s. char* mkdtemp(char* name_template) { - int err = _mktemp_s(name_template); + int err = _mktemp_s(name_template, strlen(name_template) + 1); if (err < 0) { perror("_mktemp_s"); return NULL; -- cgit v0.12