summaryrefslogtreecommitdiffstats
path: root/lib/hash.h
diff options
context:
space:
mode:
authorwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:03:14 +0200
committerwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:04:07 +0200
commitd62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch)
tree3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/hash.h
parent*: add indent control files (diff)
downloadfrr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz
frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/hash.h')
-rw-r--r--lib/hash.h104
1 files changed, 51 insertions, 53 deletions
diff --git a/lib/hash.h b/lib/hash.h
index 3b2671afa..ec3766eaa 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -27,88 +27,86 @@
DECLARE_MTYPE(HASH)
DECLARE_MTYPE(HASH_BACKET)
-/* Default hash table size. */
+/* Default hash table size. */
#define HASH_INITIAL_SIZE 256 /* initial number of backets. */
#define HASH_THRESHOLD 10 /* expand when backet. */
#define HASHWALK_CONTINUE 0
#define HASHWALK_ABORT -1
-struct hash_backet
-{
- /* if this backet is the head of the linked listed, len denotes the number of
- * elements in the list */
- int len;
+struct hash_backet {
+ /* if this backet is the head of the linked listed, len denotes the
+ * number of
+ * elements in the list */
+ int len;
- /* Linked list. */
- struct hash_backet *next;
+ /* Linked list. */
+ struct hash_backet *next;
- /* Hash key. */
- unsigned int key;
+ /* Hash key. */
+ unsigned int key;
- /* Data. */
- void *data;
+ /* Data. */
+ void *data;
};
-struct hashstats
-{
- /* number of empty hash buckets */
- _Atomic uint_fast32_t empty;
- /* sum of squares of bucket length */
- _Atomic uint_fast32_t ssq;
+struct hashstats {
+ /* number of empty hash buckets */
+ _Atomic uint_fast32_t empty;
+ /* sum of squares of bucket length */
+ _Atomic uint_fast32_t ssq;
};
-struct hash
-{
- /* Hash backet. */
- struct hash_backet **index;
+struct hash {
+ /* Hash backet. */
+ struct hash_backet **index;
- /* Hash table size. Must be power of 2 */
- unsigned int size;
+ /* Hash table size. Must be power of 2 */
+ unsigned int size;
- /* If expansion failed. */
- int no_expand;
+ /* If expansion failed. */
+ int no_expand;
- /* Key make function. */
- unsigned int (*hash_key) (void *);
+ /* Key make function. */
+ unsigned int (*hash_key)(void *);
- /* Data compare function. */
- int (*hash_cmp) (const void *, const void *);
+ /* Data compare function. */
+ int (*hash_cmp)(const void *, const void *);
- /* Backet alloc. */
- unsigned long count;
+ /* Backet alloc. */
+ unsigned long count;
- struct hashstats stats;
+ struct hashstats stats;
- /* hash name */
- char *name;
+ /* hash name */
+ char *name;
};
#define hashcount(X) ((X)->count)
-extern struct hash *hash_create (unsigned int (*) (void *),
- int (*) (const void *, const void *),
- const char *);
-extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *),
- int (*) (const void *, const void *),
- const char *);
+extern struct hash *hash_create(unsigned int (*)(void *),
+ int (*)(const void *, const void *),
+ const char *);
+extern struct hash *hash_create_size(unsigned int, unsigned int (*)(void *),
+ int (*)(const void *, const void *),
+ const char *);
-extern void *hash_get (struct hash *, void *, void * (*) (void *));
-extern void *hash_alloc_intern (void *);
-extern void *hash_lookup (struct hash *, void *);
-extern void *hash_release (struct hash *, void *);
+extern void *hash_get(struct hash *, void *, void *(*)(void *));
+extern void *hash_alloc_intern(void *);
+extern void *hash_lookup(struct hash *, void *);
+extern void *hash_release(struct hash *, void *);
-extern void hash_iterate (struct hash *,
- void (*) (struct hash_backet *, void *), void *);
+extern void hash_iterate(struct hash *, void (*)(struct hash_backet *, void *),
+ void *);
-extern void hash_walk (struct hash *,
- int (*) (struct hash_backet *, void *), void *);
+extern void hash_walk(struct hash *, int (*)(struct hash_backet *, void *),
+ void *);
-extern void hash_clean (struct hash *, void (*) (void *));
-extern void hash_free (struct hash *);
+extern void hash_clean(struct hash *, void (*)(void *));
+extern void hash_free(struct hash *);
-extern unsigned int string_hash_make (const char *);
+extern unsigned int string_hash_make(const char *);
-extern void hash_cmd_init (void);
+extern void hash_cmd_init(void);
#endif /* _ZEBRA_HASH_H */