PPP: use pbuf_coalesce() instead of private ppp_singlebuf()

pbuf_coalesce() creates a single pbuf out of a chain of pbufs, which is
exactly what ppp_singlebuf() need.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
This commit is contained in:
Axel Lin 2017-04-29 15:25:16 +08:00 committed by Sylvain Rochet
parent a942582b4b
commit 3e909bafa8

View File

@ -973,28 +973,7 @@ out:
/* merge a pbuf chain into one pbuf */
struct pbuf *ppp_singlebuf(struct pbuf *p) {
struct pbuf *q, *b;
u8_t *pl;
if(p->tot_len == p->len) {
return p;
}
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
if(!q) {
PPPDEBUG(LOG_ERR,
("ppp_singlebuf: unable to alloc new buf (%d)\n", p->tot_len));
return p; /* live dangerously */
}
for(b = p, pl = (u8_t*)q->payload; b != NULL; b = b->next) {
MEMCPY(pl, b->payload, b->len);
pl += b->len;
}
pbuf_free(p);
return q;
return pbuf_coalesce(p, PBUF_RAW);
}
/*