#### 5.2Safe C Vectors

 (require ffi/cvector) (require ffi/unsafe/cvector)
The ffi/unsafe/cvector library exports the bindings of this section. The ffi/cvector library exports the same bindings, except for the unsafe make-cvector* operation.

The cvector form can be used as a type C vectors (i.e., a pointer to a memory block).

 (_cvector mode type maybe-len) _cvector
Like _bytes, _cvector can be used as a simple type that corresponds to a pointer that is managed as a safe C vector on the Racket side. The longer form behaves similarly to the _list and _vector custom types, except that _cvector is more efficient; no Racket list or vector is needed.

 (make-cvector type length) → cvector? type : ctype? length : exact-nonnegative-integer?
Allocates a C vector using the given type and length. The resulting vector is not guaranteed to contain any particular values.

 (cvector type val ...) → cvector? type : ctype? val : any/c
Creates a C vector of the given type, initialized to the given list of vals.

 (cvector? v) → boolean? v : any/c
Returns #t if v is a C vector, #f otherwise.

 (cvector-length cvec) → exact-nonnegative-integer? cvec : cvector?
Returns the length of a C vector.

 (cvector-type cvec) → ctype? cvec : cvector?
Returns the C type object of a C vector.

 (cvector-ptr cvec) → cpointer? cvec : cvector?
Returns the pointer that points at the beginning block of the given C vector.

 (cvector-ref cvec k) → any cvec : cvector? k : exact-nonnegative-integer?
References the kth element of the cvec C vector. The result has the type that the C vector uses.

 (cvector-set! cvec k val) → void? cvec : cvector? k : exact-nonnegative-integer? val : any
Sets the kth element of the cvec C vector to val. The val argument should be a value that can be used with the type that the C vector uses.

 (cvector->list cvec) → list? cvec : cvector?
Converts the cvec C vector object to a list of values.

 (list->cvector lst type) → cvector? lst : list? type : ctype?
Converts the list lst to a C vector of the given type.

 (make-cvector* cptr type length) → cvector? cptr : any/c type : ctype? length : exact-nonnegative-integer?
Constructs a C vector using an existing pointer object. This operation is not safe, so it is intended to be used in specific situations where the type and length are known.