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.
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.
- 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
* 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
* 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