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

@@ -154,14 +154,7 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
}
#endif /* LWIP_SO_RCVBUF */
/* copy the whole packet into new pbufs */
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
if (q != NULL) {
if (pbuf_copy(q, p) != ERR_OK) {
pbuf_free(q);
q = NULL;
}
}
q = pbuf_clone(PBUF_RAW, PBUF_RAM, p);
if (q != NULL) {
u16_t len;
buf = (struct netbuf *)memp_malloc(MEMP_NETBUF);