Skip to content

Commit

Permalink
fixed missing pointer deallocation
Browse files Browse the repository at this point in the history
  • Loading branch information
soundflix committed Mar 7, 2023
1 parent 6f54432 commit d974650
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ZMAX/Sources/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,18 @@ extension AXUIElement {
extension AXValue {
public func toValue<T>() -> T? {
let pointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
defer {
pointer.deallocate()
}
let success = AXValueGetValue(self, AXValueGetType(self), pointer)
return success ? pointer.pointee : nil
}

public static func from<T>(value: T, type: AXValueType) -> AXValue? {
let pointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
defer {
pointer.deallocate()
}
pointer.pointee = value
return AXValueCreate(type, pointer)
}
Expand Down

0 comments on commit d974650

Please sign in to comment.