ffi_alloc#

Allocate $len zeroed bytes of C memory; returns the address.

Synopsis#

my $out = Peta::FFI::alloc(8);       # e.g. a sqlite3** out-param cell
Peta::FFI::call($lib, "sqlite3_open", "(po)i", ":memory:", $out);
my $db = Peta::FFI::unpack_ptr(Peta::FFI::peek($out, 8));
Peta::FFI::free($out);

What you get back#

The address of a zeroed calloc block, as an integer for o arguments. The caller owns it: every alloc needs a matching free. A $len of 0 still returns a valid 1-byte allocation.