Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / samisc.h / sa_coloff.3.md

% limb manual
% sa_coloff(3)
% limb 0.1.0
% 2023-07-24

# NAME

sa_coloff - append an array of offsets to strings from an stralloc into it

# SYNOPSIS

    #include <limb/samisc.h>

```pre hl
int sa_coloff(stralloc *<em>sa</em>, size_t <em>from</em>, size_t <em>skip</em>, size_t <em>end</em>)
```

# DESCRIPTION

The `sa_coloff`() function will scan the content of the given stralloc `sa`
starting at offset `from`, expecting to find a succession of NUL-terminated
strings after `skip` bytes, up to `end`. It will append into `sa` an array of
offsets where each string is located within `sa->s` (not accounting for `skip`).

! INFO:
! The offsets added into `sa` are actually casted as *uintptr_t* so that they
! can later be turned into full string pointers (*char \**) if needed.
! Such a conversion can be done using [sa_off2ptr](3) if `skip` is 0.

# RETURN VALUE

Upon successful completion, the `sa_coloff`() function returns the number of
strings found, or the number of elements in the array. Otherwise, it returns -1
and sets `errno` to indicate the error.

# ERRORS

The `sa_coloff`() function may fail if :

: *ENOMEM*
:: Out of memory to add pointers into `sa`

# SEE ALSO

[sa_off2ptr](3), [sa_colptr](3)