]> git.meshlink.io Git - utcp/commitdiff
Avoid calling malloc() in fast_retransmit().
authorGuus Sliepen <guus@sliepen.org>
Sun, 19 Apr 2020 14:22:40 +0000 (16:22 +0200)
committerGuus Sliepen <guus@sliepen.org>
Sun, 19 Apr 2020 14:22:40 +0000 (16:22 +0200)
utcp.c

diff --git a/utcp.c b/utcp.c
index f7c1859de2abe5ef05873bb1ef6565d449810e3d..19f6cfaf098377bc748de022bdfe506912796482 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -847,13 +847,7 @@ static void fast_retransmit(struct utcp_connection *c) {
        struct {
                struct hdr hdr;
                uint8_t data[];
-       } *pkt;
-
-       pkt = malloc(c->utcp->mtu);
-
-       if(!pkt) {
-               return;
-       }
+       } *pkt = c->utcp->pkt;
 
        pkt->hdr.src = c->src;
        pkt->hdr.dst = c->dst;
@@ -885,8 +879,6 @@ static void fast_retransmit(struct utcp_connection *c) {
        default:
                break;
        }
-
-       free(pkt);
 }
 
 static void retransmit(struct utcp_connection *c) {