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 2828// / owned by the runtime and should not be freed.
2929SWIFT_RUNTIME_EXPORT
3030const char *
31- swift_getRuntimePath ();
31+ swift_getRuntimeLibraryPath ();
3232
3333// / Return the path of the Swift root.
3434// /
@@ -40,7 +40,8 @@ swift_getRuntimePath();
4040// /
4141// / \return A string containing the full path to the Swift root directory, based
4242// / 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.
4445SWIFT_RUNTIME_EXPORT
4546const char *
4647swift_getRootPath ();
@@ -73,6 +74,6 @@ swift_getRootPath();
7374// / should be released with `free()` when no longer required.
7475SWIFT_RUNTIME_EXPORT
7576const char *
76- swift_getAuxiliaryExecutablePath (const char *name);
77+ swift_copyAuxiliaryExecutablePath (const char *name);
7778
7879#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);
7474
7575SWIFT_RUNTIME_EXPORT
7676const char *
77- swift_getRuntimePath ()
77+ swift_getRuntimeLibraryPath ()
7878{
7979 swift::once (runtimePathToken, _swift_initRuntimePath, nullptr );
8080 return runtimePath;
@@ -121,7 +121,7 @@ _swift_lookingAtBin(const char *ptr, const char *base)
121121const char *
122122_swift_getDefaultRootPath ()
123123{
124- const char *runtimePath = swift_getRuntimePath ();
124+ const char *runtimePath = swift_getRuntimeLibraryPath ();
125125 size_t runtimePathLen = std::strlen (runtimePath);
126126
127127 // Scan backwards until we find a path separator
@@ -357,7 +357,7 @@ _swift_win32NameFromNTName(LPWSTR pszFilename) {
357357
358358SWIFT_RUNTIME_EXPORT
359359const char *
360- swift_getAuxiliaryExecutablePath (const char *name)
360+ swift_copyAuxiliaryExecutablePath (const char *name)
361361{
362362 const char *rootPath = swift_getRootPath ();
363363
Original file line number Diff line number Diff line change 2222#include < sys/types.h>
2323#include < sys/stat.h>
2424
25+ #include < stdlib.h>
2526#include < stdio.h>
2627#include < string.h>
2728
@@ -60,7 +61,7 @@ containsLibSwift(const char *path) {
6061}
6162
6263int main (void ) {
63- const char *runtimePath = swift_getRuntimePath ();
64+ const char *runtimePath = swift_getRuntimeLibraryPath ();
6465
6566 // Runtime path must point to libswiftCore and must be a file.
6667
@@ -89,12 +90,14 @@ int main(void) {
8990 printf (" root path contains /lib/swift/: %s\n " ,
9091 containsLibSwift (rootPath) ? " yes" : " no" );
9192
92- const char *auxPath = swift_getAuxiliaryExecutablePath (" Foo" );
93+ const char *auxPath = swift_copyAuxiliaryExecutablePath (" Foo" );
9394
9495 // CHECK: aux path: <NULL>
9596 // CHECK-FR: aux path: {{.*[\\/]libexec[\\/]swift[\\/]Foo(\.exe)?}}
9697
9798 printf (" aux path: %s\n " , auxPath ? auxPath : " <NULL>" );
9899
100+ free (auxPath);
101+
99102 return 0 ;
100103}
You can’t perform that action at this time.
0 commit comments