batman-adv: Prefix hash struct and typedef with batadv_

Reported-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
Sven Eckelmann
2012-06-05 22:31:28 +02:00
committed by Antonio Quartulli
parent 7f223c0c32
commit 5bf74e9ca1
9 changed files with 67 additions and 64 deletions

View File

@@ -25,37 +25,39 @@
/* callback to a compare function. should compare 2 element datas for their
* keys, return 0 if same and not 0 if not same
*/
typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *);
typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,
const void *);
/* the hashfunction, should return an index
* based on the key in the data of the first
* argument and the size the second
*/
typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t);
typedef void (*hashdata_free_cb)(struct hlist_node *, void *);
typedef uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t);
typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
struct hashtable_t {
struct batadv_hashtable {
struct hlist_head *table; /* the hashtable itself with the buckets */
spinlock_t *list_locks; /* spinlock for each hash list entry */
uint32_t size; /* size of hashtable */
};
/* allocates and clears the hash */
struct hashtable_t *batadv_hash_new(uint32_t size);
struct batadv_hashtable *batadv_hash_new(uint32_t size);
/* set class key for all locks */
void batadv_hash_set_lock_class(struct hashtable_t *hash,
void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key);
/* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct hashtable_t *hash);
void batadv_hash_destroy(struct batadv_hashtable *hash);
/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
* called to remove the elements inside of the hash. if you don't remove the
* elements, memory might be leaked.
*/
static inline void batadv_hash_delete(struct hashtable_t *hash,
hashdata_free_cb free_cb, void *arg)
static inline void batadv_hash_delete(struct batadv_hashtable *hash,
batadv_hashdata_free_cb free_cb,
void *arg)
{
struct hlist_head *head;
struct hlist_node *node, *node_tmp;
@@ -89,9 +91,9 @@ static inline void batadv_hash_delete(struct hashtable_t *hash,
* Returns 0 on success, 1 if the element already is in the hash
* and -1 on error.
*/
static inline int batadv_hash_add(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose,
static inline int batadv_hash_add(struct batadv_hashtable *hash,
batadv_hashdata_compare_cb compare,
batadv_hashdata_choose_cb choose,
const void *data,
struct hlist_node *data_node)
{
@@ -134,9 +136,10 @@ out:
* structure you use with just the key filled, we just need the key for
* comparing.
*/
static inline void *batadv_hash_remove(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose, void *data)
static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
batadv_hashdata_compare_cb compare,
batadv_hashdata_choose_cb choose,
void *data)
{
uint32_t index;
struct hlist_node *node;