Skip to content

Commit 66709b6

Browse files
committed
[Explicit Module Builds] Make sure to dispose/free memory of batch scan result after decoding it.
1 parent 46b88f7 commit 66709b6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public enum DependencyScanningError: Error, DiagnosticData {
4646
}
4747
}
4848

49-
/// Wrapper for libSwiftScan, taking care of initialization, shutdown, and dependency scanning
50-
/// queries.
49+
/// Wrapper for libSwiftScan, taking care of initialization, shutdown, and dispatching dependency scanning queries.
5150
internal final class SwiftScan {
5251
/// The path to the libSwiftScan dylib.
5352
let path: AbsolutePath
@@ -66,6 +65,7 @@ internal final class SwiftScan {
6665

6766
init(dylib path: AbsolutePath) throws {
6867
self.path = path
68+
print("OPENINGNG : \(path.description)")
6969
#if os(Windows)
7070
self.dylib = try dlopen(path.pathString, mode: [])
7171
#else
@@ -169,10 +169,8 @@ internal final class SwiftScan {
169169
let resultGraphMap = try constructBatchResultGraphs(for: batchInfos,
170170
from: batchResultRef.pointee)
171171
// Free the memory allocated for the in-memory representation of the batch scan
172-
// restult, now that we have translated it.
173-
174-
// TODO: This segfaults, WHY?
175-
//api.swiftscan_batch_scan_result_dispose(batchResultRefOrNull)
172+
// result, now that we have translated it.
173+
api.swiftscan_batch_scan_result_dispose(batchResultRefOrNull)
176174
return resultGraphMap
177175
}
178176
}
@@ -184,15 +182,15 @@ private extension swiftscan_functions_t {
184182
// MARK: Optional Methods
185183
// Future optional methods can be queried here
186184

185+
186+
// MARK: Required Methods
187187
func loadRequired<T>(_ symbol: String) throws -> T {
188188
guard let sym: T = dlsym(swiftscan, symbol: symbol) else {
189189
throw DependencyScanningError.missingRequiredSymbol(symbol)
190190
}
191191
return sym
192192
}
193193

194-
// MARK: Required Methods
195-
196194
self.swiftscan_scanner_create =
197195
try loadRequired("swiftscan_scanner_create")
198196
self.swiftscan_scanner_dispose =

0 commit comments

Comments
 (0)