These functions can be used as HASH and KEY_EQUAL functions when defining new maps with "struct object *" as their key. Signed-off-by: Jeff King <peff@xxxxxxxx> --- Makefile | 1 + map-object.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 map-object.h diff --git a/Makefile b/Makefile index d512f27..1d29a95 100644 --- a/Makefile +++ b/Makefile @@ -633,6 +633,7 @@ LIB_H += map-decl.h LIB_H += map-done.h LIB_H += map-impl.h LIB_H += map-init.h +LIB_H += map-object.h LIB_H += merge-file.h LIB_H += merge-recursive.h LIB_H += mergesort.h diff --git a/map-object.h b/map-object.h new file mode 100644 index 0000000..4f98413 --- /dev/null +++ b/map-object.h @@ -0,0 +1,19 @@ +#ifndef MAP_OBJECT_H +#define MAP_OBJECT_H + +#include "object.h" + +static unsigned int hash_obj(const struct object *obj, unsigned int n) +{ + unsigned int hash; + + memcpy(&hash, obj->sha1, sizeof(unsigned int)); + return hash % n; +} + +static int obj_equal(const struct object *a, const struct object *b) +{ + return a == b; +} + +#endif /* MAP_OBJECT_H */ -- 1.7.12.rc1.7.g7a223a6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html