Jeff King <p...@peff.net> writes: > khash.h | 338 ++++++++++++++++++++ [...] > diff --git a/khash.h b/khash.h > new file mode 100644 > index 0000000..57ff603 > --- /dev/null > +++ b/khash.h > @@ -0,0 +1,338 @@ > +/* The MIT License > + > + Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attrac...@live.co __AC_KHASH_H > +#define __AC_KHASH_H [...] > +static inline khint_t __kh_oid_hash(const unsigned char *oid) > +{ > + khint_t hash; > + memcpy(&hash, oid, sizeof(hash)); > + return hash; > +} > + > +#define __kh_oid_cmp(a, b) (hashcmp(a, b) == 0) > + > +KHASH_INIT(sha1, const unsigned char *, void *, 1, __kh_oid_hash, > __kh_oid_cmp) > +typedef kh_sha1_t khash_sha1; > + > +KHASH_INIT(sha1_pos, const unsigned char *, int, 1, __kh_oid_hash, > __kh_oid_cmp) > +typedef kh_sha1_pos_t khash_sha1_pos; > + > +#endif /* __AC_KHASH_H */
Advertising
AFAICS, the part after the [...] are additions specific to git. Is that right? Can we store them in a separate khash-sha1.h or some such, to make it clearer what's what? As things stand, one has to look for an identifier that is built from macros at the far end of a file that looks like it was imported verbatim from klib(?). I don't know about you, but that just took me far too long to get right. I think I'll also lend you a hand writing Documentation/technical/api-khash.txt (expect it tomorrow) so that we also have documentation in the git style, where gitters can be expected to find it on their own. All that could then nicely fit into a commit that actually says where you conjured khash.h from and such. This information seems conspicuously absent from this commit's message :-) Furthermore, would it be a problem to name the second hash sha1_int instead? I have another use for such a hash, and I can't imagine I'm the only one. (That's not critical however, I can do the required editing in that other series.) -- Thomas Rast t...@thomasrast.ch -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at