5 ms·
A Reference Counted, Prefix Counted, String library for C. That is, automatic reference counting of strings, to eliminate manual memory management, and avoid g
by mikewarot 4y ago
A Reference Counted, Prefix Counted, String library for C.
That is, automatic reference counting of strings, to eliminate manual memory management, and avoid garbage collection.
Counted Strings (with a \x00 on the end for compatibility) solve problems with binary data in the string.
Prefix Counting means that the beginning of the structure is BEFORE the pointer, so that if you just reference the pointer, you get the first character of a "normal" null terminated C string.
Using the "cleanup" attribute support of modern C, it should be possible to make a Defer macro to allow strings going out of scope to be dereferenced, and if their reference count goes to zero, deallocation.