Show HN: C library of generic, reference-counted data structures
theck01.github.io
Show HN: C library of generic, reference-counted data structures
1–10 of 42 posts
Re: Show HN: C library of generic, reference-counted data structures
#2Re: Show HN: C library of generic, reference-counted data structures
#3Re: Show HN: C library of generic, reference-counted data structures
#4Re: Show HN: C library of generic, reference-counted data structures
#5nice. it's heartwarming to see things like this in c. in my spare time i am working on struct-sql mapping. it sometimes feels like the popular c libraries don't try hard enough to provide the convenience we get in other languages. with a little imagination (as here) i think we can push things a little further...
Re: Show HN: C library of generic, reference-counted data structures
#6Anyway, it's nice to see a portable, modern CF-like library, although of course it's too slow for some cases where code specialization is called for.
Edit: On the general subject of C data structures, in case anyone's interested, I wrote a little portable C header that provides minimal hash table functionality using macros, with a large amount of control - still generic, but totally opposite to the approach used by this library, much lower level. It's modeled after the BSD header, provides three versions (open, closed, and a higher level version), and is completely undocumented, but I'm somewhat happy with it as a proof of concept. Just throwing it out there. https://github.com/comex/cbit/blob/master/hash.h
Re: Show HN: C library of generic, reference-counted data structures
#7However I didn't do reference counting. Good job OP!
Re: Show HN: C library of generic, reference-counted data structures
#8Re: Show HN: C library of generic, reference-counted data structures
#9With regard to OBString: don't. Really. C strings are very flexible and powerful with just what's in the standard library. You don't need charAtStringIndex, for example: you have rindex and index. You don't need splitString; you have strtok_r. You don't need findSubstring; you have strstr.
If you think you need regexes, consider fnmatch, a libc function which matches shell wildcard patterns. It's always there, it's simple, and it's fast. Or you could bring in something like PCRE. In general, if you need full regexes in a small program, it might be worth rethinking whether your program should be in C anyway.
For some reason, I don't find myself using resizable array utility code much in C. It's pretty easy to do it yourself with realloc-- that's really one of the first things they should teach people learning practical C. Perhaps a small, minimal set of macros could wrap the reallocs and make it a little bit nicer.
Re: Show HN: C library of generic, reference-counted data structures
#10http://ccodearchive.net/list.html
https://github.com/rustyrussell/ccan
And GMP for arbitrary precision math (integers and floating point numbers).