Skip to content

Commit

Permalink
add release for string
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Nov 2, 2023
1 parent 9ac317f commit 49ad908
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion DXFeedFramework/Native/Events/Markets/TradeETHMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ class TradeETHMapper: Mapper {
return eventType
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class NativeInstrumentProfileReader {
address.toCStringRef())) else {
return address
}
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_String_release(thread, result))
}
return String(pointee: result)
}

Expand Down
17 changes: 9 additions & 8 deletions DXFeedFramework/Native/Property/NativeProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class NativeProperty {

static func getProperty(_ key: String) -> String? {
let thread = currentThread()
let property = dxfg_system_get_property(thread,
key.cString(using: .utf8))
if let property = property {
let result = String(utf8String: property)
dxfg_system_release_property(thread, property)
return result
} else {
return nil
if let property = try? ErrorCheck.nativeCall(thread,
dxfg_system_get_property(
thread,
key.cString(using: .utf8))) {
defer {
_ = try? ErrorCheck.nativeCall(thread, dxfg_system_release_property(thread, property))
}
return String(pointee: property)
}
return nil
}
}
6 changes: 6 additions & 0 deletions DXFeedFrameworkTests/IPFTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,10 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY
let result = try collector.createOnFixedThreadPool(numberOfThreads: 15, nameOfthread: "test_ios_thread")
XCTAssert(result, "createOnFixedThreadPool failed")
}

func testResolveSourceURL() throws {
let inputStr = "abcde"
let resultstr = DXInstrumentProfileReader.resolveSourceURL(address: inputStr)
XCTAssert(inputStr == resultstr)
}
}

0 comments on commit 49ad908

Please sign in to comment.