diff options
author | Jose <jose@zeroc.com> | 2020-04-28 23:48:25 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2020-04-28 23:51:32 +0200 |
commit | f55c6c5062f37de53cc534e25f4dba4d5d0779fb (patch) | |
tree | 89a26b3a76e7f52e38a8a16a86aacf6c8d9abdc5 /cpp/src | |
parent | Fix for testing bindists (diff) | |
download | ice-f55c6c5062f37de53cc534e25f4dba4d5d0779fb.tar.bz2 ice-f55c6c5062f37de53cc534e25f4dba4d5d0779fb.tar.xz ice-f55c6c5062f37de53cc534e25f4dba4d5d0779fb.zip |
Fix swift dangling pointer warnings - Close #821
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2swift/Gen.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 45eb33c51e7..056786dee5d 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -888,15 +888,20 @@ Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) string keyParam = "let key: " + keyType; writeMarshalUnmarshalCode(out, p->keyType(), p, keyParam, false); out << nl << "v[key] = nil as " << valueType; + out << nl << "Swift.withUnsafeMutablePointer(to: &v[key, default:nil])"; + out << sb; out << nl << "e.values[i] = Ice.DictEntry<" << keyType << ", " << valueType << ">(" << "key: key, " - << "value: UnsafeMutablePointer<" << valueType << ">(&v[key, default:nil]))"; + << "value: $0)"; + out << eb; writeMarshalUnmarshalCode(out, p->valueType(), p, "e.values[i].value.pointee", false); out << eb; out << nl << "for i in 0..<sz" << sb; - out << nl << "e.values[i].value = Swift.UnsafeMutablePointer<" << valueType - << ">(&v[e.values[i].key, default:nil])"; + out << nl << "Swift.withUnsafeMutablePointer(to: &v[e.values[i].key, default:nil])"; + out << sb; + out << nl << "e.values[i].value = $0"; + out << eb; out << eb; } else |