summaryrefslogtreecommitdiff
path: root/cpp/src/slice2swift/Gen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r--cpp/src/slice2swift/Gen.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 8a57e737181..45eb33c51e7 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -734,9 +734,12 @@ Gen::TypesVisitor::visitSequence(const SequencePtr& p)
out << nl << "var v = " << fixIdent(name) << "(repeating: nil, count: sz)";
out << nl << "for i in 0 ..< sz";
out << sb;
- out << nl << "let p = UnsafeMutablePointer<" << typeToString(p->type(), p) << ">(&v[i])";
+ out << nl << "try Swift.withUnsafeMutablePointer(to: &v[i])";
+ out << sb;
+ out << " p in";
writeMarshalUnmarshalCode(out, type, p, "p.pointee", false);
out << eb;
+ out << eb;
}
else
{