We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0dc6fe5 + 3e96e75 commit e4c0886Copy full SHA for e4c0886
Sources/Support/memmove.swift
@@ -0,0 +1,21 @@
1
+@_silgen_name("memmove")
2
+func memmove(
3
+ _ dst: UnsafeMutableRawPointer,
4
+ _ src: UnsafeRawPointer,
5
+ _ n: Int,
6
+) -> UnsafeMutableRawPointer {
7
+ let dst = unsafe dst.bindMemory(to: UInt8.self, capacity: n)
8
+ var dstSpan = unsafe MutableSpan(_unsafeStart: dst, count: n)
9
+ let src = unsafe src.bindMemory(to: UInt8.self, capacity: n)
10
+ let srcSpan = unsafe Span(_unsafeStart: src, count: n)
11
+ if unsafe dst < src {
12
+ for i in dstSpan.indices {
13
+ dstSpan[i] = srcSpan[i]
14
+ }
15
+ } else {
16
+ for i in dstSpan.indices.reversed() {
17
18
19
20
+ return .init(dst)
21
+}
0 commit comments