Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #293 from rpinz/warnings
Browse files Browse the repository at this point in the history
eliminate warnings for Swift 4.1
  • Loading branch information
tanner0101 committed May 30, 2018
2 parents 0ecc50f + 9a115ff commit e44822c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/HTTP/Parser/ParseResults.swift
Expand Up @@ -55,8 +55,13 @@ extension ParseResults {
static func remove(from parser: inout http_parser) {
if let results = parser.data {
let pointer = results.assumingMemoryBound(to: ParseResults.self)
#if swift(>=4.1)
pointer.deinitialize(count: 1)
pointer.deallocate()
#else
pointer.deinitialize()
pointer.deallocate(capacity: 1)
#endif
}
}

Expand Down
5 changes: 5 additions & 0 deletions Sources/SMTP/Utility/NSUUID+SMTPMessageID.swift
Expand Up @@ -17,8 +17,13 @@ extension NSUUID {
static internal func currentHostName() -> String {
let hname = UnsafeMutablePointer<Int8>.allocate(capacity: Int(NI_MAXHOST))
defer {
#if swift(>=4.1)
hname.deinitialize(count: Int(NI_MAXHOST))
hname.deallocate()
#else
hname.deinitialize()
hname.deallocate(capacity: Int(NI_MAXHOST))
#endif
}
let r = gethostname(hname, Int(NI_MAXHOST))
if r < 0 || hname[0] == 0 {
Expand Down
4 changes: 4 additions & 0 deletions Tests/HTTPTests/HTTPBodyTests.swift
Expand Up @@ -15,7 +15,11 @@ class HTTPBodyTests: XCTestCase {
let stream = TestStream()
_ = try stream.write("GET / HTTP/1.1")
_ = try stream.writeLineEnd()
#if swift(>=4.0)
_ = try stream.write("Content-Length: \(expected.count.description)")
#else
_ = try stream.write("Content-Length: \(expected.characters.count.description)")
#endif
_ = try stream.writeLineEnd()
_ = try stream.writeLineEnd()
_ = try stream.write(expected)
Expand Down
9 changes: 9 additions & 0 deletions Tests/HTTPTests/HTTPParsingTests.swift
Expand Up @@ -4,6 +4,7 @@ import XCTest
import Transport
@testable import HTTP

import XCTest
class HTTPParsingTests: XCTestCase {
static let allTests = [
("testParser", testParser),
Expand All @@ -23,7 +24,11 @@ class HTTPParsingTests: XCTestCase {
data += "Accept-Language: en-us\r\n"
data += "Cookie: 1=1;2=2\r\n"
data += "Content-Type: application/json; charset=utf-8\r\n"
#if swift(>=4.0)
data += "Content-Length: \(content.count)\r\n"
#else
data += "Content-Length: \(content.characters.count)\r\n"
#endif
data += "\r\n"
data += content

Expand Down Expand Up @@ -83,7 +88,11 @@ class HTTPParsingTests: XCTestCase {
data += "Host: localhost:8080\r\n"
data += "Cookie: 1=1;2=2\r\n"
data += "Content-Type: application/json; charset=utf-8\r\n"
#if swift(>=4.0)
data += "Content-Length: \(content.count)\r\n"
#else
data += "Content-Length: \(content.characters.count)\r\n"
#endif
data += "\r\n"
data += content

Expand Down

0 comments on commit e44822c

Please sign in to comment.