Skip to content

Commit 2979402

Browse files
authored
Merge pull request #191 from CodaFi/buffer-handling
Switch to a buffer pointer
2 parents 91e9f6f + c244cd1 commit 2979402

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/LLVM/ObjectFile.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class BinaryFile {
7272
case LLVMBinaryTypeMachO64L: self = .machO64L
7373
case LLVMBinaryTypeMachO64B: self = .machO64B
7474
case LLVMBinaryTypeWasm: self = .wasm
75-
default: fatalError("unknown comdat selection kind \(llvm)")
75+
default: fatalError("unknown binary type \(llvm)")
7676
}
7777
}
7878
}
@@ -186,7 +186,7 @@ public struct Section {
186186
/// The size of the contents of the section.
187187
public let size: Int
188188
/// The raw contents of the section.
189-
public let contents: String
189+
public let contents: UnsafeBufferPointer<CChar>
190190
/// The address of the section in the object file.
191191
public let address: Int
192192

@@ -197,7 +197,7 @@ public struct Section {
197197
self.sectionIterator = si
198198
self.name = String(cString: LLVMGetSectionName(si))
199199
self.size = Int(LLVMGetSectionSize(si))
200-
self.contents = String(cString: LLVMGetSectionContents(si))
200+
self.contents = UnsafeBufferPointer<CChar>(start: LLVMGetSectionContents(si), count: self.size)
201201
self.address = Int(LLVMGetSectionAddress(si))
202202
}
203203

0 commit comments

Comments
 (0)