/* 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/samisc.h>
int
sa_patrim_put(stralloc *sa, u64 id, u64 u, const char *data)
{
size_t salen = sa->len;
if (!stralloc_readyplus(sa, 18)) return 0;
sa->len += patrim_put(sa->s + sa->len, 18, 0, id, u);
if (patrim_isblob(id) && !stralloc_catb(sa, data, (size_t) u)) {
sa->len = salen;
return 0;
}
return 1;
}