https://developer.apple.com/documentation/swift/unsafemutablerawpointer

この辺に、C でいうところのmalloc から freeの処理のやり方が書かれてる。