Use function attributes to catch cases where bitratestats is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 lib/bitratestats/rte_bitrate.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h
index 979a712837..27951f3e28 100644
--- a/lib/bitratestats/rte_bitrate.h
+++ b/lib/bitratestats/rte_bitrate.h
@@ -17,16 +17,6 @@ extern "C" {
  */
 struct rte_stats_bitrates;
 
-
-/**
- * Allocate a bitrate statistics structure
- *
- * @return
- *   - Pointer to structure on success
- *   - NULL on error (zmalloc failure)
- */
-struct rte_stats_bitrates *rte_stats_bitrate_create(void);
-
 /**
  * Free bitrate statistics structure
  *
@@ -36,6 +26,16 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void);
  */
 void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data);
 
+/**
+ * Allocate a bitrate statistics structure
+ *
+ * @return
+ *   - Pointer to structure on success
+ *   - NULL on error (zmalloc failure)
+ */
+struct rte_stats_bitrates *rte_stats_bitrate_create(void)
+       __rte_malloc __rte_dealloc(rte_stats_bitrate_free, 1);
+
 /**
  * Register bitrate statistics with the metric library.
  *
-- 
2.45.2

Reply via email to