Update sdb

This commit is contained in:
pancake 2019-09-30 11:51:50 +02:00
parent 21fb73d1f8
commit 011ebf7e03
2 changed files with 5 additions and 2 deletions

View File

@ -301,6 +301,10 @@ SDB_API HT_(Kv)* Ht_(find_kv)(HtName_(Ht)* ht, const KEY_TYPE key, bool* found)
if (found) { if (found) {
*found = false; *found = false;
} }
if (!ht) {
*found = false;
return NULL;
}
HT_(Bucket) *bt = &ht->table[bucketfn (ht, key)]; HT_(Bucket) *bt = &ht->table[bucketfn (ht, key)];
ut32 key_len = calcsize_key (ht, key); ut32 key_len = calcsize_key (ht, key);

View File

@ -368,13 +368,12 @@ SDB_API int sdb_add(Sdb* s, const char *key, const char *val, ut32 cas) {
SDB_API bool sdb_exists(Sdb* s, const char *key) { SDB_API bool sdb_exists(Sdb* s, const char *key) {
ut32 pos; ut32 pos;
char ch; char ch;
SdbKv *kv;
bool found; bool found;
int klen = strlen (key) + 1; int klen = strlen (key) + 1;
if (!s) { if (!s) {
return false; return false;
} }
kv = (SdbKv*)sdb_ht_find_kvp (s->ht, key, &found); SdbKv *kv = (SdbKv*)sdb_ht_find_kvp (s->ht, key, &found);
if (found && kv) { if (found && kv) {
char *v = sdbkv_value (kv); char *v = sdbkv_value (kv);
return v && *v; return v && *v;