/* 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/patrim.h>
#include <limb/u64.h>
int
patrim_put(char *dst, size_t dlen, size_t offset, u64 id, u64 u)
{
int r, n;
if (offset >= dlen) return -1;
r = u64_pack_trim(dst + offset, dlen - offset, id);
if (r < 0) return -1;
n = u64_pack_trim(dst + offset + r, dlen - offset - r, u);
if (n < 0) return -1;
return r + n;
}