File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 17
17
18
18
#ifdef _WIN32
19
19
#include " flang/Common/windows-include.h"
20
+ #include < direct.h>
21
+ #define getcwd _getcwd
20
22
21
23
// On Windows GetCurrentProcessId returns a DWORD aka uint32_t
22
24
#include < processthreadsapi.h>
@@ -245,17 +247,16 @@ std::int32_t RTNAME(GetCwd)(
245
247
246
248
RUNTIME_CHECK (terminator, IsValidCharDescriptor (&cwd));
247
249
248
- char *buf = ( char *) std::malloc (FILENAME_MAX );
250
+ char *buf = getcwd ( nullptr , 0 );
249
251
if (!buf) {
250
- return StatMemAllocation;
251
- }
252
-
253
- if (!getcwd (buf, FILENAME_MAX)) {
254
252
return StatMissingCurrentWorkDirectory;
255
253
}
256
254
257
255
std::int64_t strLen = StringLength (buf);
258
- return CopyCharsToDescriptor (cwd, buf, strLen);
256
+ std::int32_t status = CopyCharsToDescriptor (cwd, buf, strLen);
257
+
258
+ std::free (buf);
259
+ return status;
259
260
}
260
261
261
262
} // namespace Fortran::runtime
You can’t perform that action at this time.
0 commit comments