omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / freestanding / pathlen.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | om2 |
| 3 | note pathlen: bounded borrowed-byte length. Never reads past len a. The first 0 ends the scan. |
| 4 | note An empty view (len 0), including a NULL pointer, is length 0. A nonempty NULL is refused by the binding, not here. |
| 5 | export fn pathlen a view uchar * to ulong |
| 6 | ensures le result len a |
| 7 | n = len a |
| 8 | for i ulong n |
| 9 | b = get a i |
| 10 | if eq b 0 |
| 11 | ret i |
| 12 | end |
| 13 | end |
| 14 | ret n |
| 15 | end |