lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] reference count


From: Kieran Mansley
Subject: [lwip-users] Re: [lwip] reference count
Date: Wed, 08 Jan 2003 23:41:54 -0000

On Wed, 6 Mar 2002, Mumtaz Ahmad wrote:

> Hi
> i am also confused about the use of reference count in pbufs . i would like
> some explanation of it

They are simply a count of how many references are held to this pbuf.  If
many parts of the code have a reference to a pbuf (ie. it has been copied
for some reason) then if one of them asks to free it you can't actually
dispose of the memory until all the others have finished with it too.
Therefore when you allocate a pbuf, the ref is set to 1.  When you copy it
the reference is increased by 1, and when you free it the reference is
decreased by 1.  Only when the reference gets to zero can the memory
safely be disposed of.

Kieran

[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]