X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=object.c;h=a6ef439192c1083e367f0a86cb10d93564fc9481;hb=5ffd3113d4109ae5d3595425af3ff4a781617631;hp=7e6a92c88e7b139ec03e0ff26e97e1559a06a220;hpb=f054a419419337142ffe40433aa3984ccc000624;p=git.git diff --git a/object.c b/object.c index 7e6a92c88..a6ef43919 100644 --- a/object.c +++ b/object.c @@ -45,13 +45,14 @@ int type_from_string(const char *str) static unsigned int hash_obj(struct object *obj, unsigned int n) { - unsigned int hash = *(unsigned int *)obj->sha1; + unsigned int hash; + memcpy(&hash, obj->sha1, sizeof(unsigned int)); return hash % n; } static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size) { - int j = hash_obj(obj, size); + unsigned int j = hash_obj(obj, size); while (hash[j]) { j++; @@ -61,16 +62,16 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i hash[j] = obj; } -static int hashtable_index(const unsigned char *sha1) +static unsigned int hashtable_index(const unsigned char *sha1) { unsigned int i; memcpy(&i, sha1, sizeof(unsigned int)); - return (int)(i % obj_hash_size); + return i % obj_hash_size; } struct object *lookup_object(const unsigned char *sha1) { - int i; + unsigned int i; struct object *obj; if (!obj_hash)