From c9a2aaf516ece95878e039c05bb333bac52a3cd8 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 31 Jul 2008 16:17:42 -0700 Subject: Make hash compare functions take const args The hash compare function should not be modifiying its args --- lib/hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index 76bf802a..3884051f 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -27,7 +27,7 @@ /* Allocate a new hash. */ struct hash * hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { struct hash *hash; @@ -46,7 +46,7 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), /* Allocate a new hash with default hash size. */ struct hash * hash_create (unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { return hash_create_size (HASHTABSIZE, hash_key, hash_cmp); } -- cgit v1.2.3 From aa990a9f58b5f46da95eb360049577a8833d649e Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 18 Aug 2008 14:13:29 -0700 Subject: Use XCALLOC Replace calls to XMALLOC followed by memset with XCALLOC. --- lib/hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/hash.c') diff --git a/lib/hash.c b/lib/hash.c index 3884051f..f705e5dd 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -32,9 +32,8 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), struct hash *hash; hash = XMALLOC (MTYPE_HASH, sizeof (struct hash)); - hash->index = XMALLOC (MTYPE_HASH_INDEX, + hash->index = XCALLOC (MTYPE_HASH_INDEX, sizeof (struct hash_backet *) * size); - memset (hash->index, 0, sizeof (struct hash_backet *) * size); hash->size = size; hash->hash_key = hash_key; hash->hash_cmp = hash_cmp; -- cgit v1.2.3