From ad55cb6733045a6e82bc71350223158677dd8d31 Mon Sep 17 00:00:00 2001 From: likewise Date: Mon, 11 Nov 2002 11:22:49 +0000 Subject: [PATCH] Added pbuf_ref_chain() which increases ref count of all pbufs in a chain. --- src/core/pbuf.c | 14 ++++++++++++++ src/include/lwip/pbuf.h | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/pbuf.c b/src/core/pbuf.c index bbd73511..e1765425 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -555,6 +555,20 @@ pbuf_ref(struct pbuf *p) } ++(p->ref); } + +/*------------------------------------------------------------------------------ +/* pbuf_ref_chain(): + * + * Increments the reference count of all pbufs in a chain. + */ +void +pbuf_ref_chain(struct pbuf *p) +{ + while (p != NULL) { + p->ref++; + p=p->next; + } +} /*-----------------------------------------------------------------------------------*/ /* pbuf_chain(): * diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h index cd1ab02f..d8b98eec 100644 --- a/src/include/lwip/pbuf.h +++ b/src/include/lwip/pbuf.h @@ -100,7 +100,7 @@ void pbuf_init(void); prepended by allocating another pbuf and chain in to the front of the ROM pbuf. - * PBUF_ROOL: the pbuf is allocated as a pbuf chain, with pbufs from + * PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from the pbuf pool that is allocated during pbuf_init(). */ struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag); @@ -123,12 +123,12 @@ u8_t pbuf_header(struct pbuf *p, s16_t header_size); Increments the reference count of the pbuf p. */ void pbuf_ref(struct pbuf *p); - +void pbuf_ref_chain(struct pbuf *p); /* pbuf_free(): Decrements the reference count and deallocates the pbuf if the reference count is zero. If the pbuf is a chain all pbufs in the - chain are deallocated. */ + chain are deallocated. */ u8_t pbuf_free(struct pbuf *p); /* pbuf_clen():