[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] RFC: pbuf chains and their reference counts
From: |
Leon Woestenberg |
Subject: |
[lwip-users] RFC: pbuf chains and their reference counts |
Date: |
Fri, 28 Mar 2003 01:24:26 +0100 |
Hello,
there are some subtleties in the pbuf_free() code regarding pbuf chains.
case 1: equal reference counts for each pbuf.
=> lower all counts, and if zero, free memory.
case 2: a non-decreasing reference count (i.e. staying equal or increasing)
=> lower all counts, de-allocate pbufs with reference count 0 until a pbuf
with non-zero is reached. (same as case 1 really).
case 3: a non-increasing reference count (i.e. staying equal or decreasing)
=> cannot be freed unambigiously
=> should NEVER occur, but CAN occur if:
- User has used pbuf_ref() instead of pbuf_ref_chain().
- User has chained differently referenced pbufs.
case 4: a complex variation of reference counts.
=> should NEVER occur
=> cannot be freed unambigiously
I will be running a code audit against the use of pbuf_ref() and
pbuf_ref_chain()
and will introduce asserts for the above two cases 3 and 4.
If this breaks anything, it was broken in the first place.
Regards,
Leon.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] RFC: pbuf chains and their reference counts,
Leon Woestenberg <=