Skip to content

Commit 0c49fb1

Browse files
Use new API for allocation memory with aligment
1 parent 8572437 commit 0c49fb1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Foundation/URLSession/BodySource.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ extension _BodyStreamSource : _BodySource {
7070
guard inputStream.hasBytesAvailable else {
7171
return .done
7272
}
73-
74-
let buffer = UnsafeMutableRawBufferPointer.allocate(count: length)
75-
defer {
76-
buffer.deallocate()
77-
}
73+
74+
let buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: length, alignment: MemoryLayout<UInt8>.alignment)
75+
defer { buffer.deallocate() }
7876

7977
guard let pointer = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
8078
return .error

0 commit comments

Comments
 (0)