[PATCH v2 11/15] ring: add allocation function attributes
Stephen Hemminger
stephen at networkplumber.org
Wed Jan 22 18:32:55 CET 2025
Use function attributes to catch cases where ring is allocated
but not freed correctly.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/ring/rte_ring.h | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index 63a71d5871..15340a1981 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -119,6 +119,16 @@ ssize_t rte_ring_get_memsize(unsigned int count);
int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
unsigned int flags);
+
+/**
+ * De-allocate all memory used by the ring.
+ *
+ * @param r
+ * Ring to free.
+ * If NULL then, the function does nothing.
+ */
+void rte_ring_free(struct rte_ring *r);
+
/**
* Create a new ring named *name* in memory.
*
@@ -183,16 +193,8 @@ int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
* - ENOMEM - no appropriate memory area found in which to create memzone
*/
struct rte_ring *rte_ring_create(const char *name, unsigned int count,
- int socket_id, unsigned int flags);
-
-/**
- * De-allocate all memory used by the ring.
- *
- * @param r
- * Ring to free.
- * If NULL then, the function does nothing.
- */
-void rte_ring_free(struct rte_ring *r);
+ int socket_id, unsigned int flags)
+ __rte_malloc __rte_dealloc(rte_ring_free, 1);
/**
* Dump the status of the ring to a file.
--
2.45.2
More information about the dev
mailing list