Skip to content

Commit 382d215

Browse files
committed
stdlib: SE-0101: remove the last few uses of old APIs (sizeof, alignof, strideof)
1 parent c77ecd3 commit 382d215

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
669669
public mutating func next() -> UInt8? {
670670
guard _idx < _endIdx else { return nil }
671671
defer { _idx += 1 }
672-
let bufferSize = sizeofValue(_buffer)
672+
let bufferSize = MemoryLayout._ofInstance(_buffer).size
673673
return withUnsafeMutablePointer(to: &_buffer) { ptr_ in
674674
let ptr = UnsafeMutableRawPointer(ptr_).assumingMemoryBound(to: UInt8.self)
675675
let bufferIdx = _idx % bufferSize

validation-test/stdlib/CoreAudio.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ CoreAudioTestSuite.test(
202202
CoreAudioTestSuite.test("UnsafeMutableAudioBufferListPointer.count") {
203203
let sizeInBytes = AudioBufferList.sizeInBytes(maximumBuffers: 16)
204204
let rawPtr = UnsafeMutableRawPointer.allocate(
205-
bytes: sizeInBytes, alignedTo: alignof(AudioBufferList.self))
205+
bytes: sizeInBytes, alignedTo: MemoryLayout<AudioBufferList>.alignment)
206206
let ablPtr = rawPtr.bindMemory(to: AudioBufferList.self,
207-
capacity: sizeInBytes / strideof(AudioBufferList.self))
207+
capacity: sizeInBytes / MemoryLayout<AudioBufferList>.stride)
208208

209209
// It is important that 'ablPtrWrapper' is a 'let'. We are verifying that
210210
// the 'count' property has a nonmutating setter.
@@ -219,7 +219,7 @@ CoreAudioTestSuite.test("UnsafeMutableAudioBufferListPointer.count") {
219219
expectEqual(0x7765_4321, rawPtr.load(as: UInt32.self))
220220

221221
rawPtr.deallocate(
222-
bytes: sizeInBytes, alignedTo: alignof(AudioBufferList.self))
222+
bytes: sizeInBytes, alignedTo: MemoryLayout<AudioBufferList>.alignment)
223223
}
224224

225225
CoreAudioTestSuite.test("UnsafeMutableAudioBufferListPointer.subscript(_: Int)") {
@@ -230,7 +230,7 @@ CoreAudioTestSuite.test("UnsafeMutableAudioBufferListPointer.subscript(_: Int)")
230230

231231
let ablPtr = rawPtr.bindMemory(
232232
to: AudioBufferList.self,
233-
capacity: sizeInBytes / sizeof(AudioBufferList.self))
233+
capacity: sizeInBytes / MemoryLayout<AudioBufferList>.stride)
234234

235235
// It is important that 'ablPtrWrapper' is a 'let'. We are verifying that
236236
// the subscript has a nonmutating setter.

0 commit comments

Comments
 (0)