Initializer

init(bytesNoCopy:length:)

Initializes a data object filled with a given number of bytes of data from a given buffer. 与えられたバッファからの、与えられたバイト数のデータで満たされたデータオブジェクトを初期化します。

Declaration 宣言

init(bytesNoCopy bytes: UnsafeMutableRawPointer, 
length: Int)

Parameters パラメータ

bytes

A buffer containing data for the new object. bytes must point to a memory block allocated with malloc. 新しいオブジェクトに対するデータを含んでいるバッファ。bytesは、mallocを使ってアロケートされるメモリブロックを指し示さなければなりません。

length

The number of bytes to hold from bytes. This value must not exceed the length of bytes. bytesから保持することになるバイト数。この値は、bytesの長さを越えてはなりません。

Return Value 戻り値

A data object initialized by adding to it length bytes of data from the buffer bytes. The returned object might be different than the original receiver. それにlengthバイトのデータをバッファbytesから追加することによって初期化されるデータオブジェクト。返されるオブジェクトは、オリジナルのレシーバとは異なるかもしれません。

Discussion 議論

The returned object takes ownership of the bytes pointer and frees it on deallocation. Therefore, bytes must point to a memory block allocated with malloc. 返されるオブジェクトは、bytesポインタの所有権を取ります、そしてそれをデアロケーションで自由にします。それゆえ、bytesmallocを使ってアロケートされるメモリブロックを指し示さなければなりません。

See Also 参照

Creating Data データを作成する

Related Documentation 関連文書