[PATCH 2/5] net: introduce net_free_packet to free the packet

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Mar 2 13:20:07 EST 2012


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 include/net.h |    5 +++++
 net/net.c     |    6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/net.h b/include/net.h
index d0f8341..c7da380 100644
--- a/include/net.h
+++ b/include/net.h
@@ -401,6 +401,11 @@ static inline char *net_alloc_packet(void)
 	return xmemalign(32, PKTSIZE);
 }
 
+static inline void net_free_packet(void *packet)
+{
+	free(packet);
+}
+
 struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport,
 		rx_handler_f *handler, void *ctx);
 
diff --git a/net/net.c b/net/net.c
index cbcac40..07fc23a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -402,7 +402,7 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler,
 
 	return con;
 out:
-	free(con->packet);
+	net_free_packet(con->packet);
 	free(con);
 	return ERR_PTR(ret);
 }
@@ -440,7 +440,7 @@ struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler,
 void net_unregister(struct net_connection *con)
 {
 	list_del(&con->list);
-	free(con->packet);
+	net_free_packet(con->packet);
 	free(con);
 }
 
@@ -495,7 +495,7 @@ static int net_answer_arp(unsigned char *pkt, int len)
 		return 0;
 	memcpy(packet, pkt, ETHER_HDR_SIZE + ARP_HDR_SIZE);
 	eth_send(packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
-	free(packet);
+	net_free_packet(packet);
 
 	return 0;
 }
-- 
1.7.7




More information about the barebox mailing list