Index: core/pbuf.c =================================================================== RCS file: /cvsroot/lwip/lwip/src/core/pbuf.c,v retrieving revision 1.57.2.3 diff -u -r1.57.2.3 pbuf.c --- core/pbuf.c 23 Jun 2003 22:21:51 -0000 1.57.2.3 +++ core/pbuf.c 20 Oct 2003 08:05:34 -0000 @@ -113,6 +113,7 @@ p->next = (struct pbuf *)((u8_t *)p + PBUF_POOL_BUFSIZE + sizeof(struct pbuf)); p->len = p->tot_len = PBUF_POOL_BUFSIZE; p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf))); + p->flags = PBUF_FLAG_POOL; q = p; p = p->next; } @@ -258,8 +259,6 @@ p->tot_len = length; /* set the length of the first pbuf in the chain */ p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length; - /* set pbuf type */ - p->flags = PBUF_FLAG_POOL; /* set reference count (needed here in case we fail) */ p->ref = 1; @@ -289,7 +288,6 @@ q->tot_len = rem_len; /* this pbuf length is pool size, unless smaller sized tail */ q->len = rem_len > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rem_len; - q->flags = PBUF_FLAG_POOL; q->payload = (void *)((u8_t *)q + sizeof(struct pbuf)); LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", ((u32_t)q->payload % MEM_ALIGNMENT) == 0); @@ -412,7 +410,7 @@ /* first, step over any pbufs that should remain in the chain */ rem_len = new_len; q = p; - /* this pbuf should be kept? */ + /* should this pbuf be kept? */ while (rem_len > q->len) { /* decrease remaining length by pbuf length */ rem_len -= q->len; @@ -512,7 +510,7 @@ * zero, the pbuf is deallocated. * * For a pbuf chain, this is repeated for each pbuf in the chain, until - * a non-zero reference count is encountered, or the end of the chain is + * a reference count > 1 is encountered, or the end of the chain is * reached. * * @param pbuf pbuf (chain) to be freed from one user. @@ -658,9 +656,6 @@ LWIP_ASSERT("h != NULL", h != NULL); LWIP_ASSERT("t != NULL", t != NULL); - if (t == NULL) - return; - /* proceed to last pbuf of chain */ for (p = h; p->next != NULL; p = p->next) { /* add total length of second chain to all totals of first chain */ @@ -670,7 +665,7 @@ LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); /* add total length of second chain to last pbuf total of first chain */ p->tot_len += t->tot_len; - /* chain last pbuf of h chain (p) with first of tail (t) */ + /* chain last pbuf of head (p) with first of tail (t) */ p->next = t; /* t is now referenced to one more time */ pbuf_ref(t); @@ -693,9 +688,6 @@ LWIP_ASSERT("p != NULL", p != NULL); LWIP_ASSERT("n != NULL", n != NULL); - if ((p == NULL) || (n == NULL)) - return; - /* iterate through all packets on queue */ while (p->next != NULL) { /* be very picky about pbuf chain correctness */ @@ -711,9 +703,9 @@ /* proceed to next packet on queue */ p = p->next; } - /* chain last pbuf of h chain (p) with first of tail (t) */ + /* chain last pbuf of queue with n */ p->next = n; - /* t is now referenced to one more time */ + /* n is now referenced to one more time */ pbuf_ref(n); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_queue: referencing queued packet %p\n", (void *)n)); } @@ -764,7 +756,7 @@ * by pbuf_take()! * * @note Any replaced pbufs will be freed through pbuf_free(). - * This may allocate them if they become no longer referenced. + * This may deallocate them if they become no longer referenced. * * @param p Head of pbuf chain to process *