From 0beff2477b55728603127f21a9df604b6fcf840c Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 3 Jul 2023 11:10:09 +0000 Subject: Refactor cdbmake, add cdbmake_addv, cdb_hashv Signed-off-by: Laurent Bercot --- src/libstddjb/cdbmake_addbeginend.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/libstddjb/cdbmake_addbeginend.c (limited to 'src/libstddjb/cdbmake_addbeginend.c') diff --git a/src/libstddjb/cdbmake_addbeginend.c b/src/libstddjb/cdbmake_addbeginend.c new file mode 100644 index 0000000..37d35c8 --- /dev/null +++ b/src/libstddjb/cdbmake_addbeginend.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include +#include + +#include +#include +#include +#include +#include "cdbmake-internal.h" + +int cdbmake_addend (cdbmaker *c, uint32_t keylen, uint32_t datalen, uint32_t h) +{ + diuint32 blah = { .left = h, .right = c->pos } ; + return genalloc_append(diuint32, &c->hplist, &blah) && cdbmake_posplus(c, 8) && cdbmake_posplus(c, keylen) && cdbmake_posplus(c, datalen) ; +} + +int cdbmake_addbegin (cdbmaker *c, uint32_t keylen, uint32_t datalen) +{ + char buf[8] ; + uint32_pack(buf, keylen) ; + uint32_pack(buf + 4, datalen) ; + return buffer_put(&c->b, buf, 8) == 8 ; +} -- cgit v1.2.3