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_add.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_add.c')
-rw-r--r-- | src/libstddjb/cdbmake_add.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstddjb/cdbmake_add.c b/src/libstddjb/cdbmake_add.c new file mode 100644 index 0000000..f7fd096 --- /dev/null +++ b/src/libstddjb/cdbmake_add.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include <skalibs/uint32.h> +#include <skalibs/diuint32.h> +#include <skalibs/buffer.h> +#include <skalibs/genalloc.h> +#include <skalibs/cdbmake.h> +#include "cdb-internal.h" +#include "cdbmake-internal.h" + +int cdbmake_add (cdbmaker *c, char const *key, uint32_t keylen, char const *data, uint32_t datalen) +{ + if (!cdbmake_addbegin(c, keylen, datalen) + || buffer_put(&c->b, key, keylen) < keylen + || buffer_put(&c->b, data, datalen) < datalen + || !cdbmake_addend(c, keylen, datalen, cdb_hash(key, keylen))) + { + genalloc_free(diuint32, &c->hplist) ; + return 0 ; + } + return 1 ; +} |