MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pbuf_cat

Function pbuf_cat

components/net/lwip/lwip-2.1.2/src/core/pbuf.c:852–875  ·  view source on GitHub ↗

* @ingroup pbuf * Concatenate two pbufs (each may be a pbuf chain) and take over * the caller's reference of the tail pbuf. * * @note The caller MAY NOT reference the tail pbuf afterwards. * Use pbuf_chain() for that purpose. * * This function explicitly does not check for tot_len overflow to prevent * failing to queue too long pbufs. This can produce invalid pbufs, so * handle with care!

Source from the content-addressed store, hash-verified

850 * @see pbuf_chain()
851 */
852void
853pbuf_cat(struct pbuf *h, struct pbuf *t)
854{
855 struct pbuf *p;
856
857 LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)",
858 ((h != NULL) && (t != NULL)), return;);
859
860 /* proceed to last pbuf of chain */
861 for (p = h; p->next != NULL; p = p->next) {
862 /* add total length of second chain to all totals of first chain */
863 p->tot_len = (u16_t)(p->tot_len + t->tot_len);
864 }
865 /* { p is last pbuf of first h chain, p->next == NULL } */
866 LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len);
867 LWIP_ASSERT("p->next == NULL", p->next == NULL);
868 /* add total length of second chain to last pbuf total of first chain */
869 p->tot_len = (u16_t)(p->tot_len + t->tot_len);
870 /* chain last pbuf of head (p) with first of tail (t) */
871 p->next = t;
872 /* p->next now references t, but the caller will drop its reference to t,
873 * so netto there is no change to the reference count of t.
874 */
875}
876
877/**
878 * @ingroup pbuf

Callers 15

pbuf_chainFunction · 0.70
tcp_process_refused_dataFunction · 0.70
tcp_in.cFile · 0.70
tcp_receiveFunction · 0.70
tcp_writeFunction · 0.70
START_TESTFunction · 0.50
test_tcp_netif_outputFunction · 0.50
ip6_reassFunction · 0.50
ip6_fragFunction · 0.50
ip4_reassFunction · 0.50
ip4_fragFunction · 0.50
httpc_tcp_recvFunction · 0.50

Calls

no outgoing calls

Tested by 2

START_TESTFunction · 0.40
test_tcp_netif_outputFunction · 0.40