From a5aaec673afd36d3044798f0f93a8a42c34a603f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 13 Dec 2018 19:43:12 +0100 Subject: [PATCH] Avoid escaping heap allocation --- .../WireGuardNetworkExtension/PacketTunnelProvider.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift index 8fb60b1..6d3f332 100644 --- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift +++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift @@ -159,9 +159,9 @@ class PacketTunnelProvider: NEPacketTunnelProvider { } // swiftlint:disable large_tuple -func withStringsAsGoStrings(_ s1: String, _ s2: String? = nil, _ s3: String? = nil, _ s4: String? = nil, call: @escaping ((gostring_t, gostring_t, gostring_t, gostring_t)) -> R) -> R { - func helper(_ p1: UnsafePointer?, _ p2: UnsafePointer?, _ p3: UnsafePointer?, _ p4: UnsafePointer?) -> R { +func withStringsAsGoStrings(_ s1: String, _ s2: String? = nil, _ s3: String? = nil, _ s4: String? = nil, call: ((gostring_t, gostring_t, gostring_t, gostring_t)) -> R) -> R { + func helper(_ p1: UnsafePointer?, _ p2: UnsafePointer?, _ p3: UnsafePointer?, _ p4: UnsafePointer?, _ call: ((gostring_t, gostring_t, gostring_t, gostring_t)) -> R) -> R { return call((gostring_t(p: p1, n: s1.utf8.count), gostring_t(p: p2, n: s2?.utf8.count ?? 0), gostring_t(p: p3, n: s3?.utf8.count ?? 0), gostring_t(p: p4, n: s4?.utf8.count ?? 0))) } - return helper(s1, s2, s3, s4) + return helper(s1, s2, s3, s4, call) }