diff options
author | David Rientjes <rientjes@google.com> | 2006-08-17 11:54:57 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-17 14:23:53 -0700 |
commit | a89fccd28197fa179828c8596791ff16e2268d20 (patch) | |
tree | 4a6c2b256a986fc221c0e1d5fa7d910f3b31eee8 /builtin-pack-objects.c | |
parent | d4baf9eaf47ea1ba204f1ab5ecd22326913dd081 (diff) | |
download | git-a89fccd28197fa179828c8596791ff16e2268d20.tar.gz |
Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.
Introduces global inline:
hashcmp(const unsigned char *sha1, const unsigned char *sha2)
Uses memcmp for comparison and returns the result based on the length of
the hash name (a future runtime decision).
Acked-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 448461bc48..f19f0d6046 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -441,7 +441,7 @@ static int locate_object_entry_hash(const unsigned char *sha1) memcpy(&ui, sha1, sizeof(unsigned int)); i = ui % object_ix_hashsz; while (0 < object_ix[i]) { - if (!memcmp(sha1, objects[object_ix[i]-1].sha1, 20)) + if (!hashcmp(sha1, objects[object_ix[i] - 1].sha1)) return i; if (++i == object_ix_hashsz) i = 0; @@ -607,7 +607,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1) */ for (neigh = 0; neigh < 8; neigh++) { ent = pbase_tree_cache[my_ix]; - if (ent && !memcmp(ent->sha1, sha1, 20)) { + if (ent && !hashcmp(ent->sha1, sha1)) { ent->ref++; return ent; } @@ -789,7 +789,7 @@ static void add_preferred_base(unsigned char *sha1) return; for (it = pbase_tree; it; it = it->next) { - if (!memcmp(it->pcache.sha1, tree_sha1, 20)) { + if (!hashcmp(it->pcache.sha1, tree_sha1)) { free(data); return; } @@ -931,7 +931,7 @@ static struct object_entry **create_sorted_list(entry_sort_t sort) static int sha1_sort(const struct object_entry *a, const struct object_entry *b) { - return memcmp(a->sha1, b->sha1, 20); + return hashcmp(a->sha1, b->sha1); } static struct object_entry **create_final_object_list(void) |