Welcome to little lamb

Code » limb » master » tree

[master] / src / liblimb / samisc.h / sa_off2ptr.c

/* 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 <stdint.h> /* uintptr_t */
#include <limb/samisc.h>

void
sa_off2ptr(stralloc *sa, size_t arroff, size_t n)
{
    uintptr_t *a = (uintptr_t *) (sa->s + arroff);
    for (size_t i = 0; i < n; ++i) {
        /* add the base, and turn this into a proper pointer */
        *a += (uintptr_t) sa->s;
        ++a;
    }
}