Function in ffi compiler

read_ints

fn read_ints(int lib, int ptr, int count) -> Result<Vec<int>, Error>
Import
use ffi::{read_ints};
Source: compiler/src/builtin_docs/ffi.hy

Copies count 64-bit integers (int64_t) from native memory at ptr.

For C APIs that return a pointer to an array, such as PCRE2’s pcre2_get_ovector_pointer. lib must be a handle from dload (else ErrorKind::InvalidHandle): reading native memory is part of the FFI grant. A null ptr or a count outside 0..=1048576 is ErrorKind::Unsupported. The pointer itself cannot be checked, so it must point at count readable words.

Parameters#

NameType
libint
ptrint
countint

Returns#

Result<Vec<int>, Error>

Examples#

use ffi::{read_ints};

// Start and end offsets of every group in the last match: 2 words each.
let ovector = read_ints(lib, pcre2_get_ovector_pointer_8(match_data), groups * 2)?;
let first_start = ovector[0];

See also#

  • ffi::dload
  • ffi::ErrorKind
  • declare: Looks up the C function name in a loaded library and records its signature.
  • invoke: Calls a function registered with declare, passing the tuple args.
↑ ↓ navigate ↵ open