mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-27 06:14:09 +00:00
In pbuf_take(): Got rid of variable 'f'. Fixed stylo (typo in style). Renamed 'top' to 'head'.
This commit is contained in:
parent
dbad0d5723
commit
9ea10ce05d
@ -788,28 +788,24 @@ pbuf_dechain(struct pbuf *p)
|
|||||||
* Used to queue packets on behalf of the lwIP stack, such as
|
* Used to queue packets on behalf of the lwIP stack, such as
|
||||||
* ARP based queueing.
|
* ARP based queueing.
|
||||||
*
|
*
|
||||||
* @param f Head of pbuf chain to process
|
* @param p Head of pbuf chain to process
|
||||||
*
|
*
|
||||||
* @return Pointer to new head of pbuf chain
|
* @return Pointer to new head of pbuf chain
|
||||||
*/
|
*/
|
||||||
struct pbuf *
|
struct pbuf *
|
||||||
pbuf_take(struct pbuf *f)
|
pbuf_take(struct pbuf *p)
|
||||||
{
|
{
|
||||||
struct pbuf *p, *prev, *top;
|
struct pbuf *q , *prev, *head;
|
||||||
LWIP_ASSERT("pbuf_take: f != NULL\n", f != NULL);
|
LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL);
|
||||||
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)f));
|
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p));
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
p = f;
|
head = p;
|
||||||
top = f;
|
|
||||||
/* iterate through pbuf chain */
|
/* iterate through pbuf chain */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* pbuf is of type PBUF_REF? */
|
/* pbuf is of type PBUF_REF? */
|
||||||
if (p->flags == PBUF_FLAG_REF)
|
if (p->flags == PBUF_FLAG_REF) {
|
||||||
{
|
|
||||||
/* the replacement pbuf */
|
|
||||||
struct pbuf *q;
|
|
||||||
DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
|
DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
|
||||||
/* allocate a pbuf (w/ payload) fully in RAM */
|
/* allocate a pbuf (w/ payload) fully in RAM */
|
||||||
/* PBUF_POOL buffers are faster if we can use them */
|
/* PBUF_POOL buffers are faster if we can use them */
|
||||||
@ -837,11 +833,12 @@ pbuf_take(struct pbuf *f)
|
|||||||
/* remove linkage to original pbuf */
|
/* remove linkage to original pbuf */
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
/* prev->next == p at this point */
|
/* prev->next == p at this point */
|
||||||
|
LWIP_ASSERT("prev->next == p", prev->next == p);
|
||||||
/* break chain and insert new pbuf instead */
|
/* break chain and insert new pbuf instead */
|
||||||
prev->next = q;
|
prev->next = q;
|
||||||
/* prev == NULL, so we replaced the top pbuf of the chain */
|
/* prev == NULL, so we replaced the head pbuf of the chain */
|
||||||
} else {
|
} else {
|
||||||
top = q;
|
head = q;
|
||||||
}
|
}
|
||||||
/* copy pbuf payload */
|
/* copy pbuf payload */
|
||||||
memcpy(q->payload, p->payload, p->len);
|
memcpy(q->payload, p->payload, p->len);
|
||||||
@ -860,7 +857,7 @@ pbuf_take(struct pbuf *f)
|
|||||||
p = q;
|
p = q;
|
||||||
} else {
|
} else {
|
||||||
/* deallocate chain */
|
/* deallocate chain */
|
||||||
pbuf_free(top);
|
pbuf_free(head);
|
||||||
DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p));
|
DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -875,6 +872,6 @@ pbuf_take(struct pbuf *f)
|
|||||||
} while (p);
|
} while (p);
|
||||||
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
|
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
|
||||||
|
|
||||||
return top;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user