256 Commits
Author SHA1 Message Date
Andrei Bacescu ecd765c0e3 Free the key and value copies when sdb_ht_insert fails 2026-10-30 09:33:51 +01:00
pancake b0038d5d31 Rebuild databases from scratch and fail sdb -r on write errors
sdb -r and "sdb db =" opened the existing database before loading the
text, so keys removed from the source were merged back in. Build into
an empty database instead, holding the lock on the target path.

sdb -r also exited 0 when a .sdb or .c output could not be written,
and succeeded as long as any single file did.
2026-10-30 09:17:35 +01:00
pancake 7eb5e5483e Fix use-after-free when generated C output cannot be written 2026-10-30 07:33:21 +01:00
Andrei Bacescu 3c8c579a59 Keep shared descendants when unsetting a namespace
When sdb_ns_unset() released the last reference to the removed
namespace, sdb_free() went through sdb_ns_free(), which forces the
references of every descendant to 1 and frees them, even those still
owned by a sibling namespace or by the caller; a backreference could
free the parent. Reset the namespaces with the reference-aware
sdb_ns_reset() before releasing the last reference.

Fix and tests as suggested by trufae in review.
2026-10-27 06:01:26 +01:00
Andrei Bacescu 3694329c0e Free the namespace and release its sdb in sdb_ns_unset 2026-10-27 06:01:26 +01:00
pancake 5fcc1cc908 Link internal database tests against static SDB 2026-10-04 11:05:29 +02:00
pancake 02a1653545 Fix database rereads without mmap 2026-10-04 11:05:29 +02:00
pancake 340cd2be0d Fix truncated escapes in generated databases 2026-10-04 11:05:29 +02:00
pancake 105c54560e Fix C output filenames in recursive database generation 2026-10-04 09:35:39 +02:00
pancake 070d0bd5e3 Fix exit status and output of terminal CLI options 2026-10-04 09:23:22 +02:00
curoky 0245bf42cf Honor static Meson library compilation ##build 2026-10-03 07:22:34 +02:00
pancake 68dc921992 Fix sdb_unlink never deleting the database file 2026-09-06 11:08:20 +02:00
pancake 84c15597c5 Add glob matching support to sdb_match 2026-08-13 21:38:45 +02:00
pancake 61b212fd71 Fix public API boolification 2026-08-13 20:37:41 +02:00
pancake e733771663 Fix inverted logic in dict_add making it never insert new keys 2026-08-13 10:55:39 +02:00
pancake 72ff1b2d49 Add sdb_existf and sdb_getf format apis 2026-08-12 18:25:43 +02:00
phix33 17049604e7 Add sdb_unsetf to unset formatted keys without heap allocation 2026-08-12 13:03:16 +02:00
pancake 198772a21b Implement transactional sync failure handling 2026-08-06 20:45:17 +02:00
pancake a644d6cc0b Add formatted SDB setters 2026-07-15 10:13:26 +02:00
pancake 790815bc7d Add the new sdb_num_getf api 2026-07-14 19:08:16 +02:00
pancake b2c50e519f Add apis to rename keys and prefixes 2026-06-10 20:38:18 +02:00
pancake d18673cb82 Test the custom heap with asan in the ci and fix a crash 2026-03-10 11:08:32 +01:00
pancake 85b473925c Linking fixes for the testsuite 2026-03-10 10:55:20 +01:00
pancake 281c920c1b Custom heap allocator improvements
- Fixed footer/size metadata drift during block splits and fresh mmap setup,
  which was breaking neighbor discovery and coalescing
- Fixed free-path page reclamation to coalesce first, only unmap valid page
  spans, and update the heap tail hint correctly
- Fixed realloc(ptr, 0) to act as free and return NULL, and added the missing
  allocation-failure guard before memcpy
- Simplified page rounding by removing the floating-point path
2026-03-10 08:11:00 +01:00
pancake 6f7f5e5c9d Revert the last hashtable ownership model change 2026-03-10 07:56:21 +01:00
pancake c546910cae ht: avoid freeing embedded kv entries via user callbacks 2026-03-07 16:42:50 +01:00
pancake bf29079711 Fix minunit 2025-11-17 20:21:20 +01:00
pancake 5ccf37667f Fix warning in minunit 2025-11-17 19:53:55 +01:00
pancake 9011eccf77 Disable leak checks and fix heap build 2025-07-14 11:18:22 +02:00
pancake 1a57c418b3 Add strbuf api and use it for cgen 2025-06-13 13:13:39 +02:00
pancake 72ba257a79 Test and fix all 3 memory allocators: libc, custom and mimalloc 2022-11-24 18:03:34 +01:00
pancake 5e5734edb1 Fix mimalloc test, support custom calloc 2022-11-24 18:03:34 +01:00
pancake 78a0fcc6fc Add mimalloc custom allocator test 2022-11-23 18:49:40 +01:00
pancake 3bc55289a7 Fix meson build and gperf tests 2022-11-23 18:06:17 +01:00
pancake 58790a02c6 Do not compile with debug info by default to avoid messing with cflags 2022-11-23 09:33:53 +01:00
pancake e4b166e8c3 Use sdb/sdb.h to solve include conflicts and simplify build 2022-11-18 11:19:31 +01:00
pancake 04868f1e4f Add sdb_itoas and adjust sdb_itoa signature to be in sync 2022-09-18 19:06:16 +02:00
pancake e976bb64e3 Fix issues ASAN CI, ignore leaks on hardfailing asan to avoid missing issues
* make asan vs make leak
2022-09-18 10:28:44 +02:00
pancake 9519de7733 Implement numeric key apis 2022-09-18 10:28:44 +02:00
pancake 62ccf2f69f Fix sdb_itoa() breaks function signature 2022-09-18 01:15:50 +02:00
pancake f278cf627a Initial work on a native python module 2022-08-21 00:50:13 +02:00
pancake ec2e34a1dc Cache miss optimizations and dont preincrement in fors 2022-07-02 21:33:50 +02:00
pancake 64a4532d69 Cleaner test/suite/run.sh titles 2022-05-21 21:28:29 +02:00
pancake ef69b8bcf7 Fix testsuite 2022-05-17 11:42:02 +02:00
pancake aa6d13a2a3 Remove all calls to eprintf from library apis (#248)
* fputs(stdout) is still pending to be removed, but this requires breaking API and ABI
2022-02-25 19:04:19 +01:00
pancake d76a88c0cf Use stdint types (#247) 2022-02-25 16:45:45 +01:00
pancake b6965582e9 Make sdb compilable as C++ (#245)
* Make sdb compilable as C++

* Add casts as void* is not typable enough
* Add ls_foreach_cast
* ht_inc.h is now named ht.inc
* Add 'make x' or 'make o' to compile in c++ or in a single shot
* Remove macros from text.c
* Avoid using extern when its not extern
* Add missing license headers
* Add extern "C" in all the include files
* Test C++ builds in the CI
2022-02-23 20:54:25 +01:00
meme e7d259c23a Remove TLS and make sdb thread-safe
* Nuke sdb_fmt
* Mark goto tables as const
* Mark lookup table as const
* Move nextcas into SdbKv
* Remove global hook (cannot be used without TLS, but we want to avoid
  that)
* Fix lock path to not use a static buffer
2022-01-18 09:56:32 +01:00
pancake b0c7e061ac Fix asan leaks in tests 2022-01-17 16:16:59 +01:00
pancake b9c92eac77 Minor indent in test file 2021-06-21 10:40:12 +02:00