Adopted the standard withCString for C strings throughout the library.
This commit is contained in:
@@ -43,10 +43,10 @@ extension JSON {
|
||||
|
||||
/// Call before writing each table value.
|
||||
public func addTableMember(name: String) {
|
||||
name.withPlaydateUTF8 { bytes, count in
|
||||
name.withCString { cString in
|
||||
withUnsafeMutablePointer(to: &encoder) {
|
||||
$0.pointee.addTableMember.unsafelyUnwrapped(
|
||||
$0, bytes.assumingMemoryBound(to: CChar.self), Int32(count))
|
||||
$0, cString, Int32(name.utf8.count))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,10 +80,10 @@ extension JSON {
|
||||
|
||||
/// Writes a string value.
|
||||
public func writeString(_ value: String) {
|
||||
value.withPlaydateUTF8 { bytes, count in
|
||||
value.withCString { cString in
|
||||
withUnsafeMutablePointer(to: &encoder) {
|
||||
$0.pointee.writeString.unsafelyUnwrapped(
|
||||
$0, bytes.assumingMemoryBound(to: CChar.self), Int32(count))
|
||||
$0, cString, Int32(value.utf8.count))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user