if (U_FAILURE(*pErrorCode)) {
return nullptr;
}
- MutableCodePointTrie *trie = new MutableCodePointTrie(initialValue, errorValue, *pErrorCode);
+ LocalPointer<MutableCodePointTrie> trie(
+ new MutableCodePointTrie(initialValue, errorValue, *pErrorCode), *pErrorCode);
if (U_FAILURE(*pErrorCode)) {
- delete trie;
return nullptr;
}
- return reinterpret_cast<UMutableCPTrie *>(trie);
+ return reinterpret_cast<UMutableCPTrie *>(trie.orphan());
}
U_CAPI UMutableCPTrie * U_EXPORT2
if (other == nullptr) {
return nullptr;
}
- MutableCodePointTrie *clone = new MutableCodePointTrie(
- *reinterpret_cast<const MutableCodePointTrie *>(other), *pErrorCode);
+ LocalPointer<MutableCodePointTrie> clone(
+ new MutableCodePointTrie(*reinterpret_cast<const MutableCodePointTrie *>(other), *pErrorCode), *pErrorCode);
if (U_FAILURE(*pErrorCode)) {
- delete clone;
return nullptr;
}
- return reinterpret_cast<UMutableCPTrie *>(clone);
+ return reinterpret_cast<UMutableCPTrie *>(clone.orphan());
}
U_CAPI void U_EXPORT2