SE-0205 withUnsafePointer(to:_:) and withUnsafeBytes(of:_:) for immutable values

This commit is contained in:
Gwendal Roué committed 2019-02-09 09:56:12 +01:00
1 parent 0dbfe7d9e3
commit 8cd49082ec
2 files changed
+3 -4

No files matched your search

+2 -2
View File
@@ -275,8 +275,8 @@ public final class DatabaseFunction: Hashable {
// retain and store in SQLite's buffer
let aggregateContextU = Unmanaged.passRetained(aggregateContext)
var aggregateContextP = aggregateContextU.toOpaque()
withUnsafeBytes(of: &aggregateContextP) {
let aggregateContextP = aggregateContextU.toOpaque()
withUnsafeBytes(of: aggregateContextP) {
aggregateContextBufferP.copyMemory(from: $0)
}
return aggregateContextU
+1 -2
View File
@@ -45,8 +45,7 @@ extension NSUUID: DatabaseValueConvertible {
/// UUID adopts DatabaseValueConvertible
extension UUID: DatabaseValueConvertible {
public var databaseValue: DatabaseValue {
var uuid_t = uuid
return withUnsafeBytes(of: &uuid_t) {
return withUnsafeBytes(of: uuid) {
Data(bytes: $0.baseAddress!, count: $0.count).databaseValue
}
}