This separates the khash declaration macros into three pieces: one
to declare the type, one for the function prototypes, and one for
the function declarations. This makes it easier to instantiate a
khash type one time and have a header with just the typedef and
The old macros are redefined in terms of the new ones.
When embedding khash in another project, it is convenient to be
able to replace the use of malloc/calloc/free with alternatives.
This wraps those calls with kmalloc/kcalloc/kfree, etc. macros
that can be easily redefined by the khash user to override the
Additionally, the return value from allocations was not being
checked. This adds a check whenever an allocation is performed
and a return code of -1 to indicate an allocation failure.
As with allocation functions, when embedding khash inside another
library, the use of the non-portable "inline" keyword can be tricky.
Instead of adding a #define of inline, this adds "kh_inline" which
can be defined as needed inside khash with better isolation.