Skip to content

Commit 69bad8c

Browse files
committed
[Backtracing] Rename a couple of functions, some comment changes.
Renamed a couple of functions following review feedback. Also added some extra words to the comments. rdar://103071801
1 parent 4b066d4 commit 69bad8c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

include/swift/Runtime/Paths.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/// owned by the runtime and should not be freed.
2929
SWIFT_RUNTIME_EXPORT
3030
const 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.
4445
SWIFT_RUNTIME_EXPORT
4546
const char *
4647
swift_getRootPath();
@@ -73,6 +74,6 @@ swift_getRootPath();
7374
/// should be released with `free()` when no longer required.
7475
SWIFT_RUNTIME_EXPORT
7576
const char *
76-
swift_getAuxiliaryExecutablePath(const char *name);
77+
swift_copyAuxiliaryExecutablePath(const char *name);
7778

7879
#endif // SWIFT_RUNTIME_PATHS_H

stdlib/public/runtime/Paths.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool _swift_exists(const char *path);
7474

7575
SWIFT_RUNTIME_EXPORT
7676
const 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)
121121
const 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

358358
SWIFT_RUNTIME_EXPORT
359359
const char *
360-
swift_getAuxiliaryExecutablePath(const char *name)
360+
swift_copyAuxiliaryExecutablePath(const char *name)
361361
{
362362
const char *rootPath = swift_getRootPath();
363363

test/Runtime/Paths.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
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

6263
int 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
}

0 commit comments

Comments
 (0)