OxL Reference

method List.asPtr

Pointer to the elements (valid until the list grows or is dropped). Writing through it is for FFI buffers: List<u8> of the needed length filled with zeros, then p.write(..) / a C function fills it.

Example:

oxl✓ checked in CI
use std.ffi { zeroBytes }

import c "string.h" { memset }

fn main() io {
  var buf = zeroBytes(4)
  unsafe { memset(buf.asPtr(), 7, 4) }
  print("{buf}")
}
Output
[7, 7, 7, 7]
pub(api) fn asPtr() -> *var T

Thread safety. the pointer is valid only until the list grows or is dropped; do not use it from another task while the list changes.

Since. 1.0.0-beta

Returns

*var T

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ffi/ffi.oxl:162

See also