diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-07-03 11:10:09 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-07-03 11:10:09 +0000 |
commit | 0beff2477b55728603127f21a9df604b6fcf840c (patch) | |
tree | 2d13673355974d9c74dc46b2dd84231c5b744f2e /src/libstddjb/cdbmake_addbeginend.c | |
parent | 109417b5defcd6d13c54b213c4f06272fcf0dc19 (diff) | |
download | skalibs-0beff2477b55728603127f21a9df604b6fcf840c.tar.xz |
Refactor cdbmake, add cdbmake_addv, cdb_hashv
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/cdbmake_addbeginend.c')
-rw-r--r-- | src/libstddjb/cdbmake_addbeginend.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <stdint.h> +#include <errno.h> + +#include <skalibs/uint32.h> +#include <skalibs/diuint32.h> +#include <skalibs/buffer.h> +#include <skalibs/genalloc.h> +#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 ; +} |