Merge pull request #8 from 5sw/master

Update for Swift 4/5
This commit is contained in:
Yeo Kheng Meng
2019-04-08 15:26:00 +08:00
committed by GitHub

View File

@@ -386,7 +386,7 @@ extension SerialPort {
public func readData(ofLength length: Int) throws -> Data { public func readData(ofLength length: Int) throws -> Data {
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: length) let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: length)
defer { defer {
buffer.deallocate(capacity: length) buffer.deallocate()
} }
let bytesRead = try readBytes(into: buffer, size: length) let bytesRead = try readBytes(into: buffer, size: length)
@@ -425,7 +425,7 @@ extension SerialPort {
var data = Data() var data = Data()
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 1) let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 1)
defer { defer {
buffer.deallocate(capacity: 1) buffer.deallocate()
} }
while true { while true {
@@ -461,7 +461,7 @@ extension SerialPort {
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 1) let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 1)
defer { defer {
buffer.deallocate(capacity: 1) buffer.deallocate()
} }
while true { while true {
@@ -498,7 +498,7 @@ extension SerialPort {
let size = data.count let size = data.count
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: size) let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: size)
defer { defer {
buffer.deallocate(capacity: size) buffer.deallocate()
} }
data.copyBytes(to: buffer, count: size) data.copyBytes(to: buffer, count: size)