? pbuf_cat.diff ? src/cscope.out Index: src/core/pbuf.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/core/pbuf.c,v retrieving revision 1.57.2.6 diff -u -r1.57.2.6 pbuf.c --- src/core/pbuf.c 28 Oct 2003 11:44:43 -0000 1.57.2.6 +++ src/core/pbuf.c 31 Oct 2003 09:03:42 -0000 @@ -617,7 +617,6 @@ } /** - * * Increment the reference count of the pbuf. * * @param p pbuf to increase reference counter of @@ -636,8 +635,7 @@ } /** - * - * Chain two pbufs (or pbuf chains) together. They must belong to the same packet. + * Concatenate two pbufs (or pbuf chains). They must belong to the same packet. * * @param h head pbuf (chain) * @param t tail pbuf (chain) @@ -645,11 +643,10 @@ * * The ->tot_len fields of all pbufs of the head chain are adjusted. * The ->next field of the last pbuf of the head chain is adjusted. - * The ->ref field of the first pbuf of the tail chain is adjusted. * */ void -pbuf_chain(struct pbuf *h, struct pbuf *t) +pbuf_cat(struct pbuf *h, struct pbuf *t) { struct pbuf *p; @@ -670,9 +667,29 @@ p->tot_len += t->tot_len; /* chain last pbuf of head (p) with first of tail (t) */ p->next = t; +} + +/** + * Chain two pbufs (or pbuf chains) together. They must belong to the same packet. + * It's the same as pbuf_cat with the addition that it increases the reference count + * of the tail. + * + * @param h head pbuf (chain) + * @param t tail pbuf (chain) + * @note May not be called on a packet queue. + * + * The ->tot_len fields of all pbufs of the head chain are adjusted. + * The ->next field of the last pbuf of the head chain is adjusted. + * The ->ref field of the first pbuf of the tail chain is adjusted. + * + */ +void +pbuf_chain(struct pbuf *h, struct pbuf *t) +{ + pbuf_cat(h, t); /* t is now referenced to one more time */ pbuf_ref(t); - LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)p, (void *)t)); + LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); } /* For packet queueing. Note that queued packets must be dequeued first Index: src/core/tcp_in.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/core/tcp_in.c,v retrieving revision 1.30.2.5 diff -u -r1.30.2.5 tcp_in.c --- src/core/tcp_in.c 28 Oct 2003 11:44:43 -0000 1.30.2.5 +++ src/core/tcp_in.c 31 Oct 2003 09:03:45 -0000 @@ -1013,8 +1013,7 @@ /* Chain this pbuf onto the pbuf that we will pass to the application. */ if (recv_data) { - pbuf_chain(recv_data, cseg->p); - pbuf_free(cseg->p); + pbuf_cat(recv_data, cseg->p); } else { recv_data = cseg->p; } Index: src/core/tcp_out.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/core/tcp_out.c,v retrieving revision 1.27.2.3 diff -u -r1.27.2.3 tcp_out.c --- src/core/tcp_out.c 28 Oct 2003 11:44:43 -0000 1.27.2.3 +++ src/core/tcp_out.c 31 Oct 2003 09:03:47 -0000 @@ -210,9 +210,8 @@ } ++queuelen; - /* Chain the headers and data pbufs together. */ - pbuf_chain(seg->p, p); - pbuf_free(p); + /* Concatenate the headers and data pbufs together. */ + pbuf_cat(seg->p, p); p = NULL; } @@ -286,11 +285,7 @@ useg->len + queue->len <= pcb->mss) { /* Remove TCP header from first segment. */ pbuf_header(queue->p, -TCP_HLEN); - pbuf_chain(useg->p, queue->p); - /* Free buffer which was merged. Note that the previous pbuf_chain call - * will have incremented the ref count, so here the ref count will still - * be 1 for the 1 pointer still being used on this buffer. */ - pbuf_free(queue->p); + pbuf_cat(useg->p, queue->p); useg->len += queue->len; useg->next = queue->next; Index: src/include/lwip/pbuf.h =================================================================== RCS file: /cvsroot/lwip/lwip/src/include/lwip/pbuf.h,v retrieving revision 1.13.4.1 diff -u -r1.13.4.1 pbuf.h --- src/include/lwip/pbuf.h 19 Jun 2003 11:34:02 -0000 1.13.4.1 +++ src/include/lwip/pbuf.h 31 Oct 2003 09:03:48 -0000 @@ -108,6 +108,7 @@ void pbuf_ref_chain(struct pbuf *p); u8_t pbuf_free(struct pbuf *p); u8_t pbuf_clen(struct pbuf *p); +void pbuf_cat(struct pbuf *h, struct pbuf *t); void pbuf_chain(struct pbuf *h, struct pbuf *t); struct pbuf *pbuf_take(struct pbuf *f); struct pbuf *pbuf_dechain(struct pbuf *p); Index: src/netif/slipif.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/slipif.c,v retrieving revision 1.12.2.2 diff -u -r1.12.2.2 slipif.c --- src/netif/slipif.c 28 Oct 2003 11:44:45 -0000 1.12.2.2 +++ src/netif/slipif.c 31 Oct 2003 09:03:48 -0000 @@ -145,8 +145,7 @@ } if (q != NULL) { - pbuf_chain(q, p); - pbuf_free(p); + pbuf_cat(q, p); } else { q = p; } Index: src/netif/ppp/ppp.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/ppp/ppp.c,v retrieving revision 1.4.2.3 diff -u -r1.4.2.3 ppp.c --- src/netif/ppp/ppp.c 28 Oct 2003 11:44:45 -0000 1.4.2.3 +++ src/netif/ppp/ppp.c 31 Oct 2003 09:03:51 -0000 @@ -1480,14 +1480,12 @@ pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { - pbuf_chain(pc->inHead, pc->inTail); - pbuf_free(pc->inTail); + pbuf_cat(pc->inHead, pc->inTail); } } else { pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { - pbuf_chain(pc->inHead, pc->inTail); - pbuf_free(pc->inTail); + pbuf_cat(pc->inHead, pc->inTail); } pbuf_realloc(pc->inHead, pc->inHead->tot_len - 2); @@ -1583,8 +1581,7 @@ if(pc->inTail) { pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { - pbuf_chain(pc->inHead, pc->inTail); - pbuf_free(pc->inTail); + pbuf_cat(pc->inHead, pc->inTail); } } /* If we haven't started a packet, we need a packet header. */ Index: src/netif/ppp/vj.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/netif/ppp/vj.c,v retrieving revision 1.3.2.1 diff -u -r1.3.2.1 vj.c --- src/netif/ppp/vj.c 28 Oct 2003 11:44:45 -0000 1.3.2.1 +++ src/netif/ppp/vj.c 31 Oct 2003 09:03:52 -0000 @@ -611,8 +611,7 @@ *nb = NULL; goto bad; } - pbuf_chain(np, n0); - pbuf_free(n0); + pbuf_cat(np, n0); n0 = np; } LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen);