From 9f60156fde4f33dec22749773f4cb2399aacf12d Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Wed, 19 Oct 2022 18:58:06 +0900 Subject: [PATCH] Remove unused int64, int32 hash key for fixing Svace warning Change-Id: I9bb85b566db975860e4243c39683f40e60601aed --- src/tpl_utils.h | 16 ++---------- src/tpl_utils_map.c | 74 ----------------------------------------------------- 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 21f2580..b7dfa1c 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -309,7 +309,7 @@ typedef struct _tpl_list_node tpl_list_node_t; typedef struct _tpl_list tpl_list_t; typedef struct tpl_util_map_entry tpl_util_map_entry_t; typedef struct tpl_util_map tpl_util_map_t; -typedef union tpl_util_key tpl_util_key_t; +typedef struct tpl_util_key tpl_util_key_t; typedef int (*tpl_util_hash_func_t)(const tpl_util_key_t key, int key_length); typedef int (*tpl_util_key_length_func_t)(const tpl_util_key_t key); @@ -324,9 +324,7 @@ enum _tpl_occurrence { TPL_ALL }; -union tpl_util_key { - uint32_t key32; - uint64_t key64; +struct tpl_util_key { void *ptr; /*pointer key or user defined key(string)*/ }; @@ -359,12 +357,6 @@ void tpl_util_map_init(tpl_util_map_t *map, int bucket_bits, tpl_util_key_compare_func_t key_compare_func, void *buckets); -void tpl_util_map_int32_init(tpl_util_map_t *map, int bucket_bits, - void *buckets); - -void tpl_util_map_int64_init(tpl_util_map_t *map, int bucket_bits, - void *buckets); - void tpl_util_map_pointer_init(tpl_util_map_t *map, int bucket_bits, void *buckets); @@ -375,10 +367,6 @@ tpl_util_map_create(int bucket_bits, tpl_util_hash_func_t hash_func, tpl_util_key_length_func_t key_length_func, tpl_util_key_compare_func_t key_compare_func); -tpl_util_map_t *tpl_util_map_int32_create(int bucket_bits); - -tpl_util_map_t *tpl_util_map_int64_create(int bucket_bits); - tpl_util_map_t *tpl_util_map_pointer_create(int bucket_bits); void tpl_util_map_destroy(tpl_util_map_t *map); diff --git a/src/tpl_utils_map.c b/src/tpl_utils_map.c index 0336bc4..dbfa74a 100644 --- a/src/tpl_utils_map.c +++ b/src/tpl_utils_map.c @@ -26,52 +26,6 @@ __get_bucket(tpl_util_map_t *map, const tpl_util_key_t key) } static int -__int64_hash(const tpl_util_key_t key, int key_length) -{ - uint64_t _key = key.key64; - - /* Hash functions from Thomas Wang https://gist.github.com/badboy/6267743 */ - _key = ~_key + (_key << 18); - _key ^= _key >> 31; - _key *= 21; - _key ^= _key >> 11; - _key += _key << 6; - _key ^= _key >> 22; - - return (int)_key;; -} - -static int -__int64_key_compare(const tpl_util_key_t key0, int key0_length, - const tpl_util_key_t key1, int key1_length) -{ - return (int)(key0.key64 - key1.key64); -} - -static int -__int32_hash(const tpl_util_key_t key, int key_length) -{ - uint32_t _key = (uint32_t)key.key32; - - /* Hash functions from Thomas Wang https://gist.github.com/badboy/6267743 */ - _key = ~_key + (_key << 15); - _key ^= _key >> 12; - _key += _key << 2; - _key ^= _key >> 4; - _key *= 2057; - _key ^= _key >> 16; - - return (int)_key; -} - -static int -__int32_key_compare(const tpl_util_key_t key0, int key0_length, - const tpl_util_key_t key1, int key1_length) -{ - return (int)(key0.key32 - key1.key32); -} - -static int __pointer_hash(const tpl_util_key_t key, int key_length) { #if INTPTR_MAX == INT32_MAX @@ -129,20 +83,6 @@ tpl_util_map_init(tpl_util_map_t *map, int bucket_bits, } void -tpl_util_map_int32_init(tpl_util_map_t *map, int bucket_bits, void *buckets) -{ - tpl_util_map_init(map, bucket_bits, __int32_hash, NULL, - __int32_key_compare, buckets); -} - -void -tpl_util_map_int64_init(tpl_util_map_t *map, int bucket_bits, void *buckets) -{ - tpl_util_map_init(map, bucket_bits, __int64_hash, NULL, - __int64_key_compare, buckets); -} - -void tpl_util_map_pointer_init(tpl_util_map_t *map, int bucket_bits, void *buckets) { tpl_util_map_init(map, bucket_bits, __pointer_hash, NULL, @@ -174,20 +114,6 @@ tpl_util_map_create(int bucket_bits, tpl_util_hash_func_t hash_func, } tpl_util_map_t * -tpl_util_map_int32_create(int bucket_bits) -{ - return tpl_util_map_create(bucket_bits, __int32_hash, NULL, - __int32_key_compare); -} - -tpl_util_map_t * -tpl_util_map_int64_create(int bucket_bits) -{ - return tpl_util_map_create(bucket_bits, __int64_hash, NULL, - __int64_key_compare); -} - -tpl_util_map_t * tpl_util_map_pointer_create(int bucket_bits) { return tpl_util_map_create(bucket_bits, __pointer_hash, NULL, -- 2.7.4