Skip to content

Commit a29d838

Browse files
committed
Linux: rewrite _splitpath implementation
1 parent d4525f7 commit a29d838

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Common/PlatformLinux.inl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ inline void Sleep(int ms)
8787
usleep(ms * 1000);
8888
}
8989

90-
#include <libgen.h>
90+
#include <libgen.h>
9191
inline void _splitpath (
9292
const char* path, // Path Input
9393
char* drive, // Drive : Output
9494
char* dir, // Directory : Output
9595
char* fname, // Filename : Output
9696
char* ext // Extension : Output
9797
){
98-
char *tmp = NULL;
99-
tmp = realpath(path, NULL);
98+
char tmp[PATH_MAX] = {0};
99+
if(!realpath(path, tmp))
100+
strcpy(tmp, path);
100101

101102
if(drive)
102103
strcpy(drive, "");
@@ -109,8 +110,6 @@ inline void _splitpath (
109110

110111
if(fname)
111112
strcpy(fname, basename(tmp));
112-
113-
free(tmp);
114113
}
115114

116115
#include <iostream>

0 commit comments

Comments
 (0)