DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/proc-info: remove unnecessary rte_malloc
@ 2023-08-07 20:43 Stephen Hemminger
  2023-08-08  1:11 ` fengchengwen
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2023-08-07 20:43 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Better to use malloc() which is faster and has more error
checking, as is done already for statistics.

Fixes: 077c546704da ("app/proc_info: add metrics displaying")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/proc-info/main.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..7bc43b8c793e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -19,7 +19,6 @@
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_ethdev.h>
-#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
@@ -909,24 +908,23 @@ metrics_display(int port_id)
 		return;
 	}
 
-	metrics = rte_malloc("proc_info_metrics",
-		sizeof(struct rte_metric_value) * len, 0);
+	metrics = malloc(sizeof(struct rte_metric_value) * len);
 	if (metrics == NULL) {
 		printf("Cannot allocate memory for metrics\n");
 		return;
 	}
 
-	names =  rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
+	names = malloc(sizeof(struct rte_metric_name) * len);
 	if (names == NULL) {
 		printf("Cannot allocate memory for metrics names\n");
-		rte_free(metrics);
+		free(metrics);
 		return;
 	}
 
 	if (len != rte_metrics_get_names(names, len)) {
 		printf("Cannot get metrics names\n");
-		rte_free(metrics);
-		rte_free(names);
+		free(metrics);
+		free(names);
 		return;
 	}
 
@@ -938,8 +936,8 @@ metrics_display(int port_id)
 	ret = rte_metrics_get_values(port_id, metrics, len);
 	if (ret < 0 || ret > len) {
 		printf("Cannot get metrics values\n");
-		rte_free(metrics);
-		rte_free(names);
+		free(metrics);
+		free(names);
 		return;
 	}
 
@@ -948,8 +946,8 @@ metrics_display(int port_id)
 		printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
 
 	printf("%s############################\n", nic_stats_border);
-	rte_free(metrics);
-	rte_free(names);
+	free(metrics);
+	free(names);
 }
 #endif
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-17 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 20:43 [PATCH] app/proc-info: remove unnecessary rte_malloc Stephen Hemminger
2023-08-08  1:11 ` fengchengwen
2023-10-17 19:52   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).