/* This file is part of limb https://lila.oss/limb
* Copyright (C) 2023 Olivier Brunel jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <limb/samisc.h>
int
sa_colptr(stralloc *sa, size_t from, size_t end)
{
size_t arroff = sa->len;
/* first collect the offsets from sa->s, as relocation might happen as we
* grow sa to store the array */
int n = sa_coloff(sa, from, 0, end);
if (n < 0)
return n;
/* then turn offsets into pointers */
sa_off2ptr(sa, arroff, n);
return n;
}