Skip to content

Commit 6803f43

Browse files
committed
fix: leaks in schedule
1 parent dcce99a commit 6803f43

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

DXFeedFramework/Native/Schedule/NativeDay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ import Foundation
1010
class NativeDay: NativeBox<dxfg_day_t> {
1111
deinit {
1212
let thread = currentThread()
13-
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler)))
13+
_ = try? ErrorCheck.nativeCall(thread, dxfg_Day_release(thread, native))
1414
}
1515
}

DXFeedFramework/Native/Schedule/NativeSchedule.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ class NativeSchedule {
128128
scheduleDay.startTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getStartTime(thread, day))
129129
scheduleDay.endTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getEndTime(thread, day))
130130
let sessions = try ErrorCheck.nativeCall(thread, dxfg_Day_getSessions(thread, day)).value()
131+
defer {
132+
_ = try? ErrorCheck.nativeCall(thread, dxfg_SessionList_release(thread, sessions))
133+
}
134+
131135
let count = sessions.pointee.size
132136
for index in 0..<Int(count) {
133137
if let element = sessions.pointee.elements[index] {
@@ -147,7 +151,7 @@ class NativeSchedule {
147151
let isTraiding = try ErrorCheck.nativeCall(thread, dxfg_Session_isTrading(thread, session))
148152
let day = try ErrorCheck.nativeCall(thread, dxfg_Session_getDay(thread, session)).value()
149153
defer {
150-
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(day.pointee.handler)))
154+
_ = try? ErrorCheck.nativeCall(thread, dxfg_Day_release(thread, day))
151155
}
152156
let yearMonthDay = try ErrorCheck.nativeCall(thread, dxfg_Day_getYearMonthDay(thread, day))
153157
let type = dxfg_session_type_t(UInt32(nativeType))

DXFeedFramework/Native/Schedule/NativeSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ import Foundation
1010
class NativeSession: NativeBox<dxfg_session_t> {
1111
deinit {
1212
let thread = currentThread()
13-
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler)))
13+
_ = try? ErrorCheck.nativeCall(thread, dxfg_Session_release(thread, native))
1414
}
1515
}

DXFeedFramework/Native/Utils/NativeTimeUtil.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class NativeTimeUtil {
2323
let result = try ErrorCheck.nativeCall(thread,
2424
dxfg_TimeFormat_format(thread,
2525
timeFormat.native,
26-
value))
27-
return String(pointee: result)
26+
value))
27+
return try String(nullable: result).value()
2828
}
2929

3030
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repositories {
66
}
77
}
88

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

0 commit comments

Comments
 (0)