I have a tendency to break out small stuff I write in C into their own libraries on the off-chance I need to use it in the future. This project provides a place for me to consolidate those libraries.
Implements a simple arena allocator. It is particularly useful for functions with lots of temporary allocations (strings, linked lists, etc.) as you don't have to keep track of every little allocation, and can instead free all memory used afterwards.
warn family of functions from *BSD. Also includes the
progname pair of functions.
Useful functions for creating and manipulating plain C strings.
Simple unit testing.
Find data, cache, configuration, and more directories, following the XDG Base Directory Specification.
Most of the header files are meant to be self-documenting and should have comprehensive comments describing usage. More complex libraries may have a comment in the header with further explanation.
Simply add the library you want as a subrepo or submodule. Then add the source file (if any) to your build system and include the header where necessary.
You can also copy individual files into your project as well. You should be sure to copy both the header and accompanying C file. The version of a file is included at the very top so you can easily check for updates in the future (note that the versions are not correlated, and different libraries may have different versions).
If you're worried about manually copying individual files in, updating isn't as important here because everything should be simple, relatively unchanging, and not security-critical, where not updating would mean you just miss out on getting new functions and features rather than getting updates to existing ones.
.c files have an optional dependency on
testing.h. This only
affects you if you are already using
string_util.c contain tests and could be added to your testing setup.
The upstream URL of this project is https://sr.ht/~nytpu/smol-c-libs. Send suggestions, bugs, patches, and other contributions to ~email@example.com. For help sending a patch through email, see https://git-send-email.io. You can browse the list archives at https://lists.sr.ht/~nytpu/public-inbox.