Similar to pbuf_header(-size) but de-refs header pbufs for (size >= p->len) * * @param q pbufs to operate on * @param size The number of bytes to remove from the beginning of the pbuf list. * While size >= p->len, pbufs are freed. * ATTENTION: this is the opposite direction as @ref pbuf_header, but * takes an u16_t not s16_t! * @return the new head pbuf
| 668 | * @return the new head pbuf |
| 669 | */ |
| 670 | struct pbuf * |
| 671 | pbuf_free_header(struct pbuf *q, u16_t size) |
| 672 | { |
| 673 | struct pbuf *p = q; |
| 674 | u16_t free_left = size; |
| 675 | while (free_left && p) { |
| 676 | if (free_left >= p->len) { |
| 677 | struct pbuf *f = p; |
| 678 | free_left = (u16_t)(free_left - p->len); |
| 679 | p = p->next; |
| 680 | f->next = 0; |
| 681 | pbuf_free(f); |
| 682 | } else { |
| 683 | pbuf_remove_header(p, free_left); |
| 684 | free_left = 0; |
| 685 | } |
| 686 | } |
| 687 | return p; |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * @ingroup pbuf |
no test coverage detected