Convenience function to convert hash table to an unsorted linked list.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
hash->stats.empty = hash->size;
}
+static void hash_to_list_iter(struct hash_backet *hb, void *arg)
+{
+ struct list *list = arg;
+
+ listnode_add(list, hb->data);
+}
+
+struct list *hash_to_list(struct hash *hash)
+{
+ struct list *list = list_new();
+
+ hash_iterate(hash, hash_to_list_iter, list);
+ return list;
+}
+
/* Free hash memory. You may call hash_clean before call this
function. */
void hash_free(struct hash *hash)
extern void hash_clean(struct hash *, void (*)(void *));
extern void hash_free(struct hash *);
+/*
+ * Converts a hash table to an unsorted linked list.
+ * Does not modify the hash table in any way.
+ *
+ * hash
+ * the hash to convert
+ */
+extern struct list *hash_to_list(struct hash *hash);
+
extern unsigned int string_hash_make(const char *);
extern void hash_cmd_init(void);