Skip to content

Commit

Permalink
fix: leaks in schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Jun 10, 2024
1 parent 5b4c87a commit 1734719
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DXFeedFramework/Native/Schedule/NativeDay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import Foundation
class NativeDay: NativeBox<dxfg_day_t> {
deinit {
let thread = currentThread()
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler)))
_ = try? ErrorCheck.nativeCall(thread, dxfg_Day_release(thread, native))
}
}
6 changes: 5 additions & 1 deletion DXFeedFramework/Native/Schedule/NativeSchedule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class NativeSchedule {
scheduleDay.startTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getStartTime(thread, day))
scheduleDay.endTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getEndTime(thread, day))
let sessions = try ErrorCheck.nativeCall(thread, dxfg_Day_getSessions(thread, day)).value()
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_SessionList_release(thread, sessions))
}

let count = sessions.pointee.size
for index in 0..<Int(count) {
if let element = sessions.pointee.elements[index] {
Expand All @@ -147,7 +151,7 @@ class NativeSchedule {
let isTraiding = try ErrorCheck.nativeCall(thread, dxfg_Session_isTrading(thread, session))
let day = try ErrorCheck.nativeCall(thread, dxfg_Session_getDay(thread, session)).value()
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(day.pointee.handler)))
_ = try? ErrorCheck.nativeCall(thread, dxfg_Day_release(thread, day))
}
let yearMonthDay = try ErrorCheck.nativeCall(thread, dxfg_Day_getYearMonthDay(thread, day))
let type = dxfg_session_type_t(UInt32(nativeType))
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Native/Schedule/NativeSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import Foundation
class NativeSession: NativeBox<dxfg_session_t> {
deinit {
let thread = currentThread()
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler)))
_ = try? ErrorCheck.nativeCall(thread, dxfg_Session_release(thread, native))
}
}
4 changes: 2 additions & 2 deletions DXFeedFramework/Native/Utils/NativeTimeUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class NativeTimeUtil {
let result = try ErrorCheck.nativeCall(thread,
dxfg_TimeFormat_format(thread,
timeFormat.native,
value))
return String(pointee: result)
value))
return try String(nullable: result).value()
}

}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories {
}
}

def native_version = '1.1.16'
def native_version = '1.1.18'
def name = 'graal-native-sdk'
dependencies {
implementation(group: 'com.dxfeed', name: "${name}", version: "${native_version}", classifier: 'aarch64-osx', ext: 'zip')
Expand Down

0 comments on commit 1734719

Please sign in to comment.