0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 20:03:07 +02:00

Consistently use init(owned:) for handle owners

Most wrapper types don't need the "maybe owned, maybe borrowed"
functionality of ClonableHandleOwner, but we can still be explicit
about ownership to make sure nothing gets destroyed that shouldn't.
This commit is contained in:
Jordan Rose 2020-10-02 15:02:41 -07:00
parent 934cb60a5c
commit d5e8aa7f9d
4 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ func invokeFnReturningOptionalPublicKey(fn: (UnsafeMutablePointer<OpaquePointer?
func invokeFnReturningCiphertextMessage(fn: (UnsafeMutablePointer<OpaquePointer?>?) -> SignalFfiErrorRef?) throws -> CiphertextMessage {
var handle : OpaquePointer?
try CheckError(fn(&handle))
return CiphertextMessage(raw_ptr: handle)
return CiphertextMessage(owned: handle)
}
func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePointer<SignalIdentityKeyStore>) throws -> Result) throws -> Result {

View File

@ -9,8 +9,8 @@ class CiphertextMessage {
signal_ciphertext_message_destroy(handle)
}
internal init(raw_ptr: OpaquePointer?) {
handle = raw_ptr;
internal init(owned raw_ptr: OpaquePointer?) {
handle = raw_ptr
}
func serialize() throws -> [UInt8] {

View File

@ -70,7 +70,7 @@ class PreKeySignalMessage {
func getSignalMessage() throws -> SignalMessage {
var m : OpaquePointer?
try CheckError(signal_pre_key_signal_message_get_signal_message(&m, handle))
return SignalMessage(raw_ptr: m)
return SignalMessage(owned: m)
}
internal func nativeHandle() -> OpaquePointer? {

View File

@ -8,7 +8,7 @@ class SignalMessage {
signal_message_destroy(handle)
}
internal init(raw_ptr: OpaquePointer?) {
internal init(owned raw_ptr: OpaquePointer?) {
handle = raw_ptr
}