]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Update hash.h documentation to warn of a possible crash
authorDonald Sharp <sharpd@nvidia.com>
Wed, 1 Dec 2021 22:03:38 +0000 (17:03 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 4 Feb 2022 17:15:27 +0000 (12:15 -0500)
Multiple deletions from the hash_walk or hash_iteration calls
during a single invocation of the passed in function can and
will cause the program to crash.  Warn against doing such a
thing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/hash.h

index f3b24f051b8c003af1a4d1a8aed61b9ff1c69c83..91770d181348bbc39dfcaffa4d6638b4314768ad 100644 (file)
@@ -235,9 +235,10 @@ extern void *hash_release(struct hash *hash, void *data);
 /*
  * Iterate over the elements in a hash table.
  *
- * It is safe to delete items passed to the iteration function from the hash
- * table during iteration. More than one item cannot be deleted during each
- * iteration. Please note that adding entries to the hash
+ * The passed in arg to the handler function is the only safe
+ * item to delete from the hash.
+ *
+ * Please note that adding entries to the hash
  * during the walk will cause undefined behavior in that some new entries
  * will be walked and some will not.  So do not do this.
  *
@@ -258,8 +259,10 @@ extern void hash_iterate(struct hash *hash,
 /*
  * Iterate over the elements in a hash table, stopping on condition.
  *
- * It is safe to delete items passed to the iteration function from the hash
- * table during iteration.  Please note that adding entries to the hash
+ * The passed in arg to the handler function is the only safe item
+ * to delete from the hash.
+ *
+ * Please note that adding entries to the hash
  * during the walk will cause undefined behavior in that some new entries
  * will be walked and some will not.  So do not do this.
  *