mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix: fixed some memory leaks (#2306)
This commit is contained in:
@@ -652,6 +652,7 @@ public func getIOProperties(_ entry: io_registry_entry_t) -> NSDictionary? {
|
|||||||
|
|
||||||
internal func getIOName(_ entry: io_registry_entry_t) -> String? {
|
internal func getIOName(_ entry: io_registry_entry_t) -> String? {
|
||||||
let pointer = UnsafeMutablePointer<io_name_t>.allocate(capacity: 1)
|
let pointer = UnsafeMutablePointer<io_name_t>.allocate(capacity: 1)
|
||||||
|
defer { pointer.deallocate() }
|
||||||
|
|
||||||
let result = IORegistryEntryGetName(entry, pointer)
|
let result = IORegistryEntryGetName(entry, pointer)
|
||||||
if result != kIOReturnSuccess {
|
if result != kIOReturnSuccess {
|
||||||
|
|||||||
@@ -314,6 +314,7 @@ public class FrequencyReader: Reader<[Double]> {
|
|||||||
self.channels = self.getChannels()
|
self.channels = self.getChannels()
|
||||||
var dict: Unmanaged<CFMutableDictionary>?
|
var dict: Unmanaged<CFMutableDictionary>?
|
||||||
self.subscription = IOReportCreateSubscription(nil, self.channels, &dict, 0, nil)
|
self.subscription = IOReportCreateSubscription(nil, self.channels, &dict, 0, nil)
|
||||||
|
dict?.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func read() {
|
public override func read() {
|
||||||
|
|||||||
Reference in New Issue
Block a user