Instance Method

copyMemory(from:byteCount:)

Copies the specified number of bytes from the given raw pointer’s memory into this pointer’s memory.

Declaration

func copyMemory(from source: UnsafeRawPointer, byteCount: Int)

Parameters

source

A pointer to the memory to copy bytes from. The memory in the region source..<(source + byteCount) must be initialized to a trivial type.

byteCount

The number of bytes to copy. byteCount must not be negative.

Discussion

If the byteCount bytes of memory referenced by this pointer are bound to a type T, then T must be a trivial type, this pointer and source must be properly aligned for accessing T, and byteCount must be a multiple of MemoryLayout<T>.stride.

After calling copyMemory(from:byteCount:), the byteCount bytes of memory referenced by this pointer are initialized to raw bytes. If the memory is bound to type T, then it contains values of type T.