Remove sdb_remove, we have sdb_unset

This commit is contained in:
pancake committed 2026-06-10 17:56:04 +02:00
1 parent 7ea2fb1845
commit 798eb98f62
3 files changed
+28 -11

No files matched your search

-1
View File
@@ -178,7 +178,6 @@ SDB_API char *sdb_querys(Sdb* s, char *buf, size_t len, const char *cmd);
SDB_API char *sdb_querysf(Sdb* s, char *buf, size_t buflen, const char *fmt, ...);
SDB_API int sdb_query_file(Sdb *s, const char* file);
SDB_API bool sdb_exists(Sdb*, const char *key);
SDB_API bool sdb_remove(Sdb*, const char *key, ut32 cas);
SDB_API int sdb_unset(Sdb*, const char *key, ut32 cas);
SDB_API int sdb_nunset(Sdb*, ut64 nkey, ut32 cas);
SDB_API int sdb_unset_like(Sdb *s, const char *k);
+4 -7
View File
@@ -306,12 +306,9 @@ SDB_API int sdb_unset(Sdb* s, const char *key, ut32 cas) {
}
SDB_API int sdb_nunset(Sdb* s, ut64 nkey, ut32 cas) {
return sdb_nset (s, nkey, "", cas);
}
/* remove from memory */
SDB_API bool sdb_remove(Sdb *s, const char *key, ut32 cas) {
return sdb_ht_delete (s->ht, key);
char buf[SDB_NUM_BUFSZ];
const char *key = sdb_itoa (nkey, 16, buf, sizeof (buf));
return sdb_unset (s, key, cas);
}
// alias for '-key=str'.. '+key=str' concats
@@ -905,7 +902,7 @@ SDB_API bool sdb_sync(Sdb* s) {
const char *kvv = sdbkv_value (kv);
if (kvv && *kvv && !kv->expire) {
if (sdb_disk_insert (s, sdbkv_key (kv), sdbkv_value (kv))) {
sdb_remove (s, sdbkv_key (kv), 0);
sdb_ht_delete (s->ht, sdbkv_key (kv));
}
}
}
+24 -3
View File
@@ -14,10 +14,31 @@ int main() {
v = sdb_const_get (s, "foo", NULL);
if (v && !strcmp ("bar", v)) {
eprintf ("OK syncget\n");
} else {
eprintf ("ERROR syncget: Keys not accessible after sync\n");
sdb_free (s);
return 0;
unlink (DBFILE);
return 1;
}
eprintf ("ERROR syncget: Keys not accessible after sync\n");
sdb_unset (s, "foo", 0);
v = sdb_const_get (s, "foo", NULL);
if (v) {
eprintf ("ERROR syncget: Unset key still accessible before sync\n");
sdb_free (s);
unlink (DBFILE);
return 1;
}
sdb_sync (s);
sdb_free (s);
return 1;
s = sdb_new (".", DBFILE, 0);
v = sdb_const_get (s, "foo", NULL);
if (v) {
eprintf ("ERROR syncget: Unset key still accessible after reopen\n");
sdb_free (s);
unlink (DBFILE);
return 1;
}
sdb_free (s);
unlink (DBFILE);
return 0;
}