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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h index 979a712837..75883f8779 100644 --- a/lib/bitratestats/rte_bitrate.h +++ b/lib/bitratestats/rte_bitrate.h @@ -7,6 +7,8 @@ #include <stdint.h> +#include <rte_common.h> + #ifdef __cplusplus extern "C" { #endif @@ -17,16 +19,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 +28,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