mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer This adds a "mutating" initialize to UnsafePointer to make Immutable -> Mutable conversions explicit. These are quick fixes to stdlib, overlays, and test cases that are necessary in order to remove arbitrary UnsafePointer conversions. Many cases can be expressed better up by reworking the surrounding code, but we first need a working starting point.
This commit is contained in:
@@ -427,7 +427,9 @@ public struct UTF8 : UnicodeCodec {
|
||||
}
|
||||
|
||||
public static func _nullCodeUnitOffset(in input: UnsafePointer<CodeUnit>) -> Int {
|
||||
return Int(_swift_stdlib_strlen(UnsafePointer(input)))
|
||||
// Relying on a permissive memory model in C.
|
||||
let cstr = unsafeBitCast(input, to: UnsafePointer<CChar>.self)
|
||||
return Int(_swift_stdlib_strlen(cstr))
|
||||
}
|
||||
// Support parsing C strings as-if they are UTF8 strings.
|
||||
public static func _nullCodeUnitOffset(in input: UnsafePointer<CChar>) -> Int {
|
||||
|
||||
Reference in New Issue
Block a user