<< Previous | Next >> | |
|
void * pnext( Pool_t * p, void * e );
Description
- Get the next allocated element in a root pool. The pool MUST be set to being a linked pool using
pool_link(p, <non-zero>)
; otherwise, the results are undefined.
- You can easily iterate through all of the allocated elements of a root pool using the following construct:
void * e;
Pool_t * p;
for (e = pfirst(p); e; e = pnext(p, e)) {
...
}Parameters
- p
- Pool handle structure, as previously passed to
pool_init()
.
- e
- Previous element address, obtained by, e.g.,
pfirst()
. This must be an allocated element in the given pool; otherwise, the results are undefined. Be careful when iterating through a list and deleting elements usingpfree()
: once the element is deleted, it is no longer valid to pass its address to this function.
- If this parameter is null, then the result is the same as
pfirst()
. This ensures the invariantpnext(p, pprev(p, e)) == e
.
Return value
null
: There are no more elements
!null
: Pointer to next allocated element
Library
- POOL.LIB
See Also
- pool_init, pool_link, palloc, pfree, pfirst, pprev
Dynamic C Functions | << Previous | Next >> | rabbit.com |