X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=object.c;h=a6ef439192c1083e367f0a86cb10d93564fc9481;hb=e1c068869216c8c231c1585bbfa9fda42b4756f8;hp=7e6a92c88e7b139ec03e0ff26e97e1559a06a220;hpb=2a5643da732b70004920f75efa1ebdc2a6ed1689;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)