diff options
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 ; +} |