From 3509dd49c0b826b200b68e728ebb9707a91e3079 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 1 Sep 2020 16:02:12 -0400 Subject: [PATCH] lib: add doc to clear-up hash_iterate multi deletion Add some header documentation to make it clear that you cannot delete more than one item during each iteration. Doing so could cause memory corruption for next pointer if its also deleted from the table. Signed-off-by: Stephen Worley --- lib/hash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hash.h b/lib/hash.h index e7ba3187f5..00953ff3b3 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -236,7 +236,8 @@ 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. Please note that adding entries to the hash + * table during iteration. More than one item cannot be deleted during each + * iteration. 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. *