aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-13 19:43:12 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-13 19:43:12 +0100
commit7323a0061228adee564ef67658b32fdafffc4e7d (patch)
tree1242f1e5a062b06ecd6b9b1a2f2d9bc64406ad90
parentTidy up str to gostr conversion (diff)
downloadwireguard-apple-7323a0061228adee564ef67658b32fdafffc4e7d.tar.xz
wireguard-apple-7323a0061228adee564ef67658b32fdafffc4e7d.zip
Avoid escaping heap allocation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift6
1 files changed, 3 insertions, 3 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 8fb60b1d..6d3f3321 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -159,9 +159,9 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
// swiftlint:disable large_tuple
-func withStringsAsGoStrings<R>(_ 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<Int8>?, _ p2: UnsafePointer<Int8>?, _ p3: UnsafePointer<Int8>?, _ p4: UnsafePointer<Int8>?) -> R {
+func withStringsAsGoStrings<R>(_ 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<Int8>?, _ p2: UnsafePointer<Int8>?, _ p3: UnsafePointer<Int8>?, _ p4: UnsafePointer<Int8>?, _ 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)
}