Use pbuf_clone to replace pbuf_alloc+pbuf_copy

Use pbuf_clone() to simplify the code a bit.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin
2017-12-19 16:26:23 +08:00
committed by Dirk Ziegelmeier
parent 4cfef8acab
commit 61e90d9fc0
3 changed files with 4 additions and 23 deletions

View File

@@ -1012,13 +1012,7 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
}
if (copy_needed) {
/* copy the whole packet into new pbufs */
p = pbuf_alloc(PBUF_LINK, q->tot_len, PBUF_RAM);
if (p != NULL) {
if (pbuf_copy(p, q) != ERR_OK) {
pbuf_free(p);
p = NULL;
}
}
p = pbuf_clone(PBUF_LINK, PBUF_RAM, q);
} else {
/* referencing the old pbuf is enough */
p = q;