attractivechaos/klib — pull request #7 by arrbee (2012-08-31 23:28:42+00:00)
Title: Libgit2 khash extensions

Hey there!

For https://github.com/libgit2/libgit2 we replaced our hashtable implementation with khash a few months ago and it has been great for us! Thank you! :heart_eyes:

We had to make a few changes to allow us to embed khash into libgit2 and I thought they might be useful to push back upstream. I've split this into 5 separate commits, but there are really 3 main things we were trying to achieve:

1. make khash easier to embed with separate macros for typedefs, function prototypes, memory allocation and inlining
2. add allocation failure checking (which changes the return value of `kh_resize_ ## name`)
3. add a couple of `foreach` macros for iterating over the keys and values stored in the hash

You are welcome to take all, some, or none of this, as you like. If you'd prefer me to split this into separate pull requests or change the way it's written or anything else, just let me know, but I thought it might be easier to show everything in one place at first.