diff options
Diffstat (limited to 'net/batman-adv/hash.h')
-rw-r--r-- | net/batman-adv/hash.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h index e75df6be4f22..eba8f2a55ccc 100644 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: |
2 | * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: | ||
3 | * | 2 | * |
4 | * Simon Wunderlich, Marek Lindner | 3 | * Simon Wunderlich, Marek Lindner |
5 | * | 4 | * |
@@ -16,7 +15,6 @@ | |||
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | * 02110-1301, USA | 17 | * 02110-1301, USA |
19 | * | ||
20 | */ | 18 | */ |
21 | 19 | ||
22 | #ifndef _NET_BATMAN_ADV_HASH_H_ | 20 | #ifndef _NET_BATMAN_ADV_HASH_H_ |
@@ -24,15 +22,15 @@ | |||
24 | 22 | ||
25 | #include <linux/list.h> | 23 | #include <linux/list.h> |
26 | 24 | ||
27 | /* callback to a compare function. should | 25 | /* callback to a compare function. should compare 2 element datas for their |
28 | * compare 2 element datas for their keys, | 26 | * keys, return 0 if same and not 0 if not same |
29 | * return 0 if same and not 0 if not | 27 | */ |
30 | * same */ | ||
31 | typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); | 28 | typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); |
32 | 29 | ||
33 | /* the hashfunction, should return an index | 30 | /* the hashfunction, should return an index |
34 | * based on the key in the data of the first | 31 | * based on the key in the data of the first |
35 | * argument and the size the second */ | 32 | * argument and the size the second |
33 | */ | ||
36 | typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); | 34 | typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); |
37 | typedef void (*hashdata_free_cb)(struct hlist_node *, void *); | 35 | typedef void (*hashdata_free_cb)(struct hlist_node *, void *); |
38 | 36 | ||
@@ -54,7 +52,8 @@ void batadv_hash_destroy(struct hashtable_t *hash); | |||
54 | 52 | ||
55 | /* remove the hash structure. if hashdata_free_cb != NULL, this function will be | 53 | /* remove the hash structure. if hashdata_free_cb != NULL, this function will be |
56 | * called to remove the elements inside of the hash. if you don't remove the | 54 | * called to remove the elements inside of the hash. if you don't remove the |
57 | * elements, memory might be leaked. */ | 55 | * elements, memory might be leaked. |
56 | */ | ||
58 | static inline void hash_delete(struct hashtable_t *hash, | 57 | static inline void hash_delete(struct hashtable_t *hash, |
59 | hashdata_free_cb free_cb, void *arg) | 58 | hashdata_free_cb free_cb, void *arg) |
60 | { | 59 | { |
@@ -80,8 +79,7 @@ static inline void hash_delete(struct hashtable_t *hash, | |||
80 | batadv_hash_destroy(hash); | 79 | batadv_hash_destroy(hash); |
81 | } | 80 | } |
82 | 81 | ||
83 | /** | 82 | /* hash_add - adds data to the hashtable |
84 | * hash_add - adds data to the hashtable | ||
85 | * @hash: storage hash table | 83 | * @hash: storage hash table |
86 | * @compare: callback to determine if 2 hash elements are identical | 84 | * @compare: callback to determine if 2 hash elements are identical |
87 | * @choose: callback calculating the hash index | 85 | * @choose: callback calculating the hash index |
@@ -91,7 +89,6 @@ static inline void hash_delete(struct hashtable_t *hash, | |||
91 | * Returns 0 on success, 1 if the element already is in the hash | 89 | * Returns 0 on success, 1 if the element already is in the hash |
92 | * and -1 on error. | 90 | * and -1 on error. |
93 | */ | 91 | */ |
94 | |||
95 | static inline int hash_add(struct hashtable_t *hash, | 92 | static inline int hash_add(struct hashtable_t *hash, |
96 | hashdata_compare_cb compare, | 93 | hashdata_compare_cb compare, |
97 | hashdata_choose_cb choose, | 94 | hashdata_choose_cb choose, |
@@ -134,7 +131,8 @@ out: | |||
134 | /* removes data from hash, if found. returns pointer do data on success, so you | 131 | /* removes data from hash, if found. returns pointer do data on success, so you |
135 | * can remove the used structure yourself, or NULL on error . data could be the | 132 | * can remove the used structure yourself, or NULL on error . data could be the |
136 | * structure you use with just the key filled, we just need the key for | 133 | * structure you use with just the key filled, we just need the key for |
137 | * comparing. */ | 134 | * comparing. |
135 | */ | ||
138 | static inline void *hash_remove(struct hashtable_t *hash, | 136 | static inline void *hash_remove(struct hashtable_t *hash, |
139 | hashdata_compare_cb compare, | 137 | hashdata_compare_cb compare, |
140 | hashdata_choose_cb choose, void *data) | 138 | hashdata_choose_cb choose, void *data) |