X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=object.c;h=c9ca481498281adab056a364a3854180456f20f3;hb=6ead3972f54e290b255b9c5379a2f9a35ec9f847;hp=3259862ab2eeeb3adcd52c24c801fd4d4e3212b7;hpb=070879ca93a7d358086f4c8aff4553493dcb9210;p=git.git diff --git a/object.c b/object.c index 3259862a..c9ca4814 100644 --- a/object.c +++ b/object.c @@ -13,17 +13,19 @@ int track_object_refs = 1; static int hashtable_index(const unsigned char *sha1) { - unsigned int i = *(unsigned int *)sha1; + unsigned int i; + memcpy(&i, sha1, sizeof(unsigned int)); return (int)(i % obj_allocs); } static int find_object(const unsigned char *sha1) { - int i = hashtable_index(sha1); + int i; if (!objs) return -1; + i = hashtable_index(sha1); while (objs[i]) { if (memcmp(sha1, objs[i]->sha1, 20) == 0) return i; @@ -58,7 +60,7 @@ void created_object(const unsigned char *sha1, struct object *obj) objs = xrealloc(objs, obj_allocs * sizeof(struct object *)); memset(objs + count, 0, (obj_allocs - count) * sizeof(struct object *)); - for (i = 0; i < count; i++) + for (i = 0; i < obj_allocs; i++) if (objs[i]) { int j = find_object(objs[i]->sha1); if (j != i) {