aboutsummaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-03-06 12:46:09 -0800
committerJunio C Hamano <gitster@pobox.com>2008-03-09 00:43:48 -0800
commitd1f128b0509dce8b492c233b36131f096fd71274 (patch)
tree4aa480380652effa3a1276b2df20879b92b9993a /hash.c
parentbcbe5a515e837873f24dc9a764fa31e3ade45bb5 (diff)
downloadgit-d1f128b0509dce8b492c233b36131f096fd71274.tar.gz
git-d1f128b0509dce8b492c233b36131f096fd71274.tar.xz
Add 'const' where appropriate to index handling functions
This is in an effort to make the source index of 'unpack_trees()' as being const, and thus making the compiler help us verify that we only access it for reading. The constification also extended to some of the hashing helpers that get called indirectly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index d9ec82fa6..1cd4c9d5c 100644
--- a/hash.c
+++ b/hash.c
@@ -9,7 +9,7 @@
* the existing entry, or the empty slot if none existed. The caller
* can then look at the (*ptr) to see whether it existed or not.
*/
-static struct hash_table_entry *lookup_hash_entry(unsigned int hash, struct hash_table *table)
+static struct hash_table_entry *lookup_hash_entry(unsigned int hash, const struct hash_table *table)
{
unsigned int size = table->size, nr = hash % size;
struct hash_table_entry *array = table->array;
@@ -66,7 +66,7 @@ static void grow_hash_table(struct hash_table *table)
free(old_array);
}
-void *lookup_hash(unsigned int hash, struct hash_table *table)
+void *lookup_hash(unsigned int hash, const struct hash_table *table)
{
if (!table->array)
return NULL;
@@ -81,7 +81,7 @@ void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
return insert_hash_entry(hash, ptr, table);
}
-int for_each_hash(struct hash_table *table, int (*fn)(void *))
+int for_each_hash(const struct hash_table *table, int (*fn)(void *))
{
int sum = 0;
unsigned int i;