The bstring library provides a string abstraction data type for the C language as a memory safe alternative to null terminated buffers.
This is a fork of Paul Hsieh's Better String Library. The following features (or mis-features, depending on your point of view) are included:
- Build system (Meson+Ninja)
- Updated test suite based on Check
- Add memory profiling with Valgrind to the workflow
- Add continuous integration via GitHub Actions
- Remove C++ wrapper code, returning this to a pure C library
- Documentation generation with Doxygen
- Other various code quality and reliability improvements
Currently this fork should be binary-compatible with the original code. The
only source incompatibility is the removal of the const_bstring type.
Just use const bstring instead.
The bstring library is available as a binary package in various distributions. The shared library and development headers can be installed with their respective package manager.
This is the easiest option if you have the option for your distribution.
The current packaging status as reported by repology.org:
The repository currently includes a Meson+Ninja build system.
The library itself doesn't have any dependencies beyond a C compiler, but the test suite requires the Check unit testing framework, while the documentation generation requires Doxygen.
Configure the build directory with Meson.
$ meson setup build
Alternatively, enable building the documentation and test suite.
$ meson setup build -Denable-docs=true -Denable-tests=true
Then compile and install.
$ meson compile -C build
$ sudo meson install -C build
A test suite is available if Check is is installed.
$ meson test -C build
If Valgrind is installed the test suite can be checked for memory leaks.
$ meson test --wrapper='valgrind --leak-check=full --error-exitcode=1' -C build
The original documentation has been migrated into the header files and converted to the Doxygen format. The generated output can be found online.
The original documentation essays are available in the source distribution and are included in the Doxygen output.
These essays have been reformatted for easier reading. Minor edits have been made to reflect changes to the codebase.
The Better String Library is released under the BSD 3-Clause License.