c와 swift의 포인터(작업중…)

cswift
const Type *UnsafePointer<Type>
const void *UnsafeRawPointer
Type *UnsafeMutablePointer<Type>
void *UnsafeMutableRawPointer

**클래스**
cswift
Type * cosnt *UnsafePointer<Type>
Type * __strong *UnsafeMutablePointer<Type>
Type **AutoreleasingUnsafeMutablePointer<Type>

**함수**
cswift
int (*) (void)@convention () -> Int32

**Null**
cswift
const Type * _NonnullUsafePointer<Type>
const Type * _NullableUnsafePointer<Type>?
const Type * _Null_unspecifiedUnsafePointer<Type>!

**포인터의 계산**
cswift
int p[] = {3, 2, 1, 0};
int a = *(p+1); => 2
let values = [3, 2, 1, 0]
var arr: UnsafePointer = UnsafePointer(values)
let a: Int = (arr + 1).pointee => 2

**타입 사이즈 계산** * c의 *sizeof, strideof* 함수의 역할
struct timeval { ... }
MemoryLayout<timeval>.size => 16, timeval의 데이터 크기
MemoryLayout<timeval>.stride => 16, timeval이 메모리에서 차지하는 실제 영역의 크기
MemoryLayout<timeval>.alignment => 8, timeval의 메모리 주소 정렬, timeval은 8바이트의 배수로 메모리를 차지함