[PATCH v5 11/16] ring: add allocation function attributes
Stephen Hemminger
stephen at networkplumber.org
Sat Jan 25 03:11:24 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>
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
---
lib/ring/rte_ring.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index 63a71d5871..28bfbde1f1 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -34,6 +34,7 @@
* for more information.
*/
+#include <rte_common.h>
#include <rte_ring_core.h>
#include <rte_ring_elem.h>
@@ -119,6 +120,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 +194,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