cdbmake_add.c (609B)
1 /* ISC license. */ 2 3 #include <skalibs/uint32.h> 4 #include <skalibs/diuint32.h> 5 #include <skalibs/buffer.h> 6 #include <skalibs/genalloc.h> 7 #include <skalibs/cdbmake.h> 8 #include "cdb-internal.h" 9 #include "cdbmake-internal.h" 10 11 int cdbmake_add (cdbmaker *c, char const *key, uint32_t keylen, char const *data, uint32_t datalen) 12 { 13 if (!cdbmake_addbegin(c, keylen, datalen) 14 || buffer_put(&c->b, key, keylen) < keylen 15 || buffer_put(&c->b, data, datalen) < datalen 16 || !cdbmake_addend(c, keylen, datalen, cdb_hash(key, keylen))) 17 { 18 genalloc_free(diuint32, &c->hplist) ; 19 return 0 ; 20 } 21 return 1 ; 22 }