mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
There were a few logs related to bad memory access within libSession and the `toLibSession` convention which we'd originally setup made me nervous as C-friendly objects would be allocated in Swift and then assigned to C struct properties but I'm not sure how the memory would actually behave in this case. This updated approach unfortunately involves a bunch of duplicate code within 'TypeConversion+Utilities' (and some horrible type aliases for tuples) but as a result we now have compile-time safe 'get' and 'set' functions for any C struct which conforms to `CAccessible` and `CMutable`. The other nice benefit about this change is that the new `set` functions copy memory across into the C structs so we can have more confidence that the memory ownership has shifted to the libSession side of things.
8 lines
170 B
Swift
8 lines
170 B
Swift
// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public protocol MutableIdentifiable: Identifiable {
|
|
mutating func setId(_ id: ID)
|
|
}
|