825 |
/* prev->next == p at this point */ |
/* prev->next == p at this point */ |
826 |
/* break chain and insert new pbuf instead */ |
/* break chain and insert new pbuf instead */ |
827 |
prev->next = q; |
prev->next = q; |
|
/* p is no longer pointed to by prev or by our caller, |
|
|
* as the caller must do p = pbuf_take(p); so free it |
|
|
* from reference through linkage. |
|
|
* note that we have set p->next to NULL already so that |
|
|
* we will not free the rest of the chain by accident. |
|
|
*/ |
|
|
pbuf_free(p); |
|
828 |
/* prev == NULL, so we replaced the top pbuf of the chain */ |
/* prev == NULL, so we replaced the top pbuf of the chain */ |
829 |
} else |
} else |
830 |
top = q; |
top = q; |
835 |
/* do not copy ref, since someone else might be using the old buffer */ |
/* do not copy ref, since someone else might be using the old buffer */ |
836 |
/* pbuf is not freed, as this is the responsibility of the application */ |
/* pbuf is not freed, as this is the responsibility of the application */ |
837 |
DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q)); |
DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q)); |
838 |
|
/* p is no longer pointed to by prev or by our caller, |
839 |
|
* as the caller must do p = pbuf_take(p); so free it |
840 |
|
* from reference through linkage. |
841 |
|
* note that we have set p->next to NULL already so that |
842 |
|
* we will not free the rest of the chain by accident. |
843 |
|
*/ |
844 |
|
pbuf_free(p); |
845 |
p = q; |
p = q; |
846 |
} |
} |
847 |
else |
else |