[PATCH v3 14/15] telemetry: add allocation function attributes
Stephen Hemminger
stephen at networkplumber.org
Thu Jan 23 17:28:14 CET 2025
Use function attributes to catch cases where telemetry data
is allocated but not freed correctly.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
lib/telemetry/rte_telemetry.h | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 2ccfc73a5f..c4554e4028 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -414,16 +414,6 @@ __rte_experimental
int
rte_telemetry_register_cmd_arg(const char *cmd, telemetry_arg_cb fn, void *arg, const char *help);
-/**
- * Get a pointer to a container with memory allocated. The container is to be
- * used embedded within an existing telemetry dict/array.
- *
- * @return
- * Pointer to a container.
- */
-struct rte_tel_data *
-rte_tel_data_alloc(void);
-
/**
* @internal
* Free a container that has memory allocated.
@@ -435,6 +425,17 @@ rte_tel_data_alloc(void);
void
rte_tel_data_free(struct rte_tel_data *data);
+/**
+ * Get a pointer to a container with memory allocated. The container is to be
+ * used embedded within an existing telemetry dict/array.
+ *
+ * @return
+ * Pointer to a container.
+ */
+struct rte_tel_data *
+rte_tel_data_alloc(void)
+ __rte_malloc __rte_dealloc(rte_tel_data_free, 1);
+
#ifdef __cplusplus
}
#endif
--
2.45.2
More information about the dev
mailing list