Skip to content

Commit

Permalink
add release for promise results
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Mar 5, 2024
1 parent 1d191e1 commit a11329b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DXFeedFramework/Native/Promise/NativePromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class NativePromise {
let listPointer = try ErrorCheck.nativeCall(thread,
dxfg_Promise_List_EventType_getResult(thread,
promiseEvents))
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_CList_EventType_release(thread, listPointer))
}
var results = [MarketEvent]()
let size = listPointer.pointee.size
for index in 0..<Int(size) {
Expand All @@ -95,6 +98,9 @@ class NativePromise {
let res = try promise?.withMemoryRebound(to: dxfg_promise_event_t.self, capacity: 1, { promiseEvent in
let result = try ErrorCheck.nativeCall(thread, dxfg_Promise_EventType_getResult(thread, promiseEvent))
let marketEvent = try EventMapper().fromNative(native: result)
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_EventType_release(thread, result))
}
self.result = marketEvent
return marketEvent
})
Expand Down

0 comments on commit a11329b

Please sign in to comment.