Adopted the standard withCString for C strings throughout the library.

This commit is contained in:
2026-09-18 11:58:57 +02:00
parent 575165dec4
commit 89c8d7a04c
22 changed files with 71 additions and 115 deletions
@@ -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))
}
}
}