]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/hash.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / hash.c
index 37f6cdcc8f86a4c3d65e405131942fa2d1fe1367..641c75136872800825d1795233e643e74406873a 100644 (file)
@@ -38,7 +38,7 @@ static struct list *_hashes;
 
 struct hash *hash_create_size(unsigned int size,
                              unsigned int (*hash_key)(void *),
-                             int (*hash_cmp)(const void *, const void *),
+                             bool (*hash_cmp)(const void *, const void *),
                              const char *name)
 {
        struct hash *hash;
@@ -67,7 +67,7 @@ struct hash *hash_create_size(unsigned int size,
 }
 
 struct hash *hash_create(unsigned int (*hash_key)(void *),
-                        int (*hash_cmp)(const void *, const void *),
+                        bool (*hash_cmp)(const void *, const void *),
                         const char *name)
 {
        return hash_create_size(HASH_INITIAL_SIZE, hash_key, hash_cmp, name);
@@ -241,21 +241,15 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
        unsigned int i;
        struct hash_backet *hb;
        struct hash_backet *hbnext;
-       uint32_t count = 0;
 
-       for (i = 0; i < hash->size; i++) {
+       for (i = 0; i < hash->size; i++)
                for (hb = hash->index[i]; hb; hb = hbnext) {
                        /* get pointer to next hash backet here, in case (*func)
                         * decides to delete hb by calling hash_release
                         */
                        hbnext = hb->next;
                        (*func)(hb, arg);
-                       count++;
-
                }
-               if (count == hash->count)
-                       return;
-       }
 }
 
 void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
@@ -265,7 +259,6 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
        struct hash_backet *hb;
        struct hash_backet *hbnext;
        int ret = HASHWALK_CONTINUE;
-       uint32_t count = 0;
 
        for (i = 0; i < hash->size; i++) {
                for (hb = hash->index[i]; hb; hb = hbnext) {
@@ -276,10 +269,7 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
                        ret = (*func)(hb, arg);
                        if (ret == HASHWALK_ABORT)
                                return;
-                       count++;
                }
-               if (count == hash->count)
-                       return;
        }
 }
 
@@ -328,7 +318,7 @@ void hash_free(struct hash *hash)
                if (_hashes) {
                        listnode_delete(_hashes, hash);
                        if (_hashes->count == 0) {
-                               list_delete_and_null(&_hashes);
+                               list_delete(&_hashes);
                        }
                }
        }