Skip to content

Commit b5127aa

Browse files
committed
Adjust private API withArrayOfCStrings.
Produce UnsafeMutablePointers instead of UnsafePointers, because that matches the signatures of posix_spawn, execve, and similar.
1 parent 36739f7 commit b5127aa

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

stdlib/private/SwiftPrivate/SwiftPrivate.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public func scatter<T>(_ a: [T], _ idx: [Int]) -> [T] {
7373
}
7474

7575
public func withArrayOfCStrings<R>(
76-
_ args: [String], _ body: ([UnsafePointer<CChar>?]) -> R
76+
_ args: [String], _ body: ([UnsafeMutablePointer<CChar>?]) -> R
7777
) -> R {
7878

7979
let argsCounts = Array(args.map { $0.utf8.count + 1 })
@@ -87,10 +87,10 @@ public func withArrayOfCStrings<R>(
8787
argsBuffer.append(0)
8888
}
8989

90-
return argsBuffer.withUnsafeBufferPointer {
90+
return argsBuffer.withUnsafeMutableBufferPointer {
9191
(argsBuffer) in
92-
let ptr = UnsafePointer<CChar>(argsBuffer.baseAddress!)
93-
var cStrings: [UnsafePointer<CChar>?] = argsOffsets.map { ptr + $0 }
92+
let ptr = UnsafeMutablePointer<CChar>(argsBuffer.baseAddress!)
93+
var cStrings: [UnsafeMutablePointer<CChar>?] = argsOffsets.map { ptr + $0 }
9494
cStrings[cStrings.count - 1] = nil
9595
return body(cStrings)
9696
}

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func swift_posix_spawn(
5555
_ file: UnsafePointer<Int8>,
5656
_ file_actions: UnsafePointer<swift_posix_spawn_file_actions_t>?,
5757
_ attrp: UnsafePointer<posix_spawnattr_t>?,
58-
_ argv: UnsafePointer<UnsafePointer<Int8>?>,
58+
_ argv: UnsafePointer<UnsafeMutablePointer<Int8>?>,
5959
_ envp: UnsafePointer<UnsafeMutablePointer<Int8>?>?) -> CInt
6060

6161
/// Calls POSIX `pipe()`.

0 commit comments

Comments
 (0)