File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 28
28
// / owned by the runtime and should not be freed.
29
29
SWIFT_RUNTIME_EXPORT
30
30
const char *
31
- swift_getRuntimePath ();
31
+ swift_getRuntimeLibraryPath ();
32
32
33
33
// / Return the path of the Swift root.
34
34
// /
@@ -40,7 +40,8 @@ swift_getRuntimePath();
40
40
// /
41
41
// / \return A string containing the full path to the Swift root directory, based
42
42
// / either on the location of the Swift runtime, or on the `SWIFT_ROOT`
43
- // / environment variable if set.
43
+ // / environment variable if set. The string is owned by the runtime
44
+ // / and should not be freed.
44
45
SWIFT_RUNTIME_EXPORT
45
46
const char *
46
47
swift_getRootPath ();
@@ -73,6 +74,6 @@ swift_getRootPath();
73
74
// / should be released with `free()` when no longer required.
74
75
SWIFT_RUNTIME_EXPORT
75
76
const char *
76
- swift_getAuxiliaryExecutablePath (const char *name);
77
+ swift_copyAuxiliaryExecutablePath (const char *name);
77
78
78
79
#endif // SWIFT_RUNTIME_PATHS_H
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ bool _swift_exists(const char *path);
74
74
75
75
SWIFT_RUNTIME_EXPORT
76
76
const char *
77
- swift_getRuntimePath ()
77
+ swift_getRuntimeLibraryPath ()
78
78
{
79
79
swift::once (runtimePathToken, _swift_initRuntimePath, nullptr );
80
80
return runtimePath;
@@ -121,7 +121,7 @@ _swift_lookingAtBin(const char *ptr, const char *base)
121
121
const char *
122
122
_swift_getDefaultRootPath ()
123
123
{
124
- const char *runtimePath = swift_getRuntimePath ();
124
+ const char *runtimePath = swift_getRuntimeLibraryPath ();
125
125
size_t runtimePathLen = std::strlen (runtimePath);
126
126
127
127
// Scan backwards until we find a path separator
@@ -357,7 +357,7 @@ _swift_win32NameFromNTName(LPWSTR pszFilename) {
357
357
358
358
SWIFT_RUNTIME_EXPORT
359
359
const char *
360
- swift_getAuxiliaryExecutablePath (const char *name)
360
+ swift_copyAuxiliaryExecutablePath (const char *name)
361
361
{
362
362
const char *rootPath = swift_getRootPath ();
363
363
Original file line number Diff line number Diff line change 22
22
#include < sys/types.h>
23
23
#include < sys/stat.h>
24
24
25
+ #include < stdlib.h>
25
26
#include < stdio.h>
26
27
#include < string.h>
27
28
@@ -60,7 +61,7 @@ containsLibSwift(const char *path) {
60
61
}
61
62
62
63
int main (void ) {
63
- const char *runtimePath = swift_getRuntimePath ();
64
+ const char *runtimePath = swift_getRuntimeLibraryPath ();
64
65
65
66
// Runtime path must point to libswiftCore and must be a file.
66
67
@@ -89,12 +90,14 @@ int main(void) {
89
90
printf (" root path contains /lib/swift/: %s\n " ,
90
91
containsLibSwift (rootPath) ? " yes" : " no" );
91
92
92
- const char *auxPath = swift_getAuxiliaryExecutablePath (" Foo" );
93
+ const char *auxPath = swift_copyAuxiliaryExecutablePath (" Foo" );
93
94
94
95
// CHECK: aux path: <NULL>
95
96
// CHECK-FR: aux path: {{.*[\\/]libexec[\\/]swift[\\/]Foo(\.exe)?}}
96
97
97
98
printf (" aux path: %s\n " , auxPath ? auxPath : " <NULL>" );
98
99
100
+ free (auxPath);
101
+
99
102
return 0 ;
100
103
}
You can’t perform that action at this time.
0 commit comments