chickadee » foreign » types » scheme-pointer

scheme-pointertype
(scheme-pointer TYPE)type
nonnull-scheme-pointertype
(nonnull-scheme-pointer TYPE)type

An untyped pointer to the contents of a non-immediate Scheme object; for example, the raw byte contents of a bytevector. Only allowed as an argument type, not a return type.

The optional element type TYPE may be used to specify what C type should be used in the generated code. This avoids the need to cast the argument.

The value #f is also allowed and is passed as a NULL pointer. For the nonnull- variant, passing #f will raise an exception.

Don't confuse this type with (c-pointer ...) which means something different (a machine-pointer object).

scheme-pointer is typically used to get a pointer to the raw byte content of number vectors. But if you pass in a SRFI-4 vector other than u8vector, you will get a pointer to a bytevector object header (not the vectors's contents), which is almost certainly wrong. Instead, convert to a number vector beforehand, or use a SRFI-4 specific type. u8vector and bytevector are synonymous and do not have an indirection pointer to the contents, the contents follow directly the header.