interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / freestanding / pathlen.om

15 lines · 416 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2om2
3note pathlen: bounded borrowed-byte length. Never reads past len a. The first 0 ends the scan.
4note An empty view (len 0), including a NULL pointer, is length 0. A nonempty NULL is refused by the binding, not here.
5export fn pathlen a view uchar * to ulong
6ensures le result len a
7n = len a
8for i ulong n
9b = get a i
10if eq b 0
11ret i
12end
13end
14ret n
15end