Skip to content

Commit bf1840d

Browse files
authored
Merge pull request #578 from apple/SE-0101
[SE-0101] Migrate sizeof() to MemoryLayout
2 parents e46929a + a29a594 commit bf1840d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tests/POSIXTests/ReaddirTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import XCTest
1212

1313
import POSIX
1414

15+
extension MemoryLayout {
16+
fileprivate static func ofInstance(_: @autoclosure () -> T) -> MemoryLayout<T>.Type {
17+
return MemoryLayout<T>.self
18+
}
19+
}
20+
1521
class ReaddirTests: XCTestCase {
1622
func testName() {
1723
do {
@@ -38,7 +44,7 @@ class ReaddirTests: XCTestCase {
3844

3945
do {
4046
var s = dirent()
41-
let n = sizeof(s.d_name.dynamicType)
47+
let n = MemoryLayout.ofInstance(s.d_name).size
4248
withUnsafeMutablePointer(to: &s.d_name) { ptr in
4349
let ptr = unsafeBitCast(ptr, to: UnsafeMutablePointer<UInt8>.self)
4450
for i in 0 ..< n {

0 commit comments

Comments
 (0)