[PATCH v3 01/36] lib: update documentation of XXX_free() functions

Stephen Hemminger stephen at networkplumber.org
Wed Feb 9 20:17:13 CET 2022


These functions all behave like libc free() and do
nothing if handed a NULL pointer. The code is already doing
this, this patch just documents the behavior.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/hash/rte_hash.h       | 4 +++-
 lib/mempool/rte_mempool.h | 1 +
 lib/ring/rte_ring.h       | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 6067aad95431..7fa9702742a9 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -174,8 +174,10 @@ rte_hash_find_existing(const char *name);
 
 /**
  * De-allocate all memory used by hash table.
+ *
  * @param h
- *   Hash table to free
+ *   Hash table to free, if NULL, the function does nothing.
+ *
  */
 void
 rte_hash_free(struct rte_hash *h);
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 1e7a3c15273c..1d3cdf7f2209 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1101,6 +1101,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
  *
  * @param mp
  *   A pointer to the mempool structure.
+ *   If NULL then, the function does nothing.
  */
 void
 rte_mempool_free(struct rte_mempool *mp);
diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index ab6b4244c89e..980e92e59493 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -193,7 +193,8 @@ struct rte_ring *rte_ring_create(const char *name, unsigned int count,
  * De-allocate all memory used by the ring.
  *
  * @param r
- *   Ring to free
+ *   Ring to free.
+ *   If NULL then, the function does nothing.
  */
 void rte_ring_free(struct rte_ring *r);
 
-- 
2.34.1



More information about the dev mailing list