<< Previous | Next >> | |
|
long pxprev( Pool_t * p, long e );
Description
- Get the previous allocated element in an xmem 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 an xmem pool using the following construct:
long e;
Pool_t * p;
for (e = pxlast(p); e; e = pxprev(p, e)) {
...
}Parameters
- p
- Pool handle structure, as previously passed to
pool_xinit()
.
- e
- Previous element address, obtained by e.g.,
pxlast()
. 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 usingpxfree()
: once the element is deleted, it is no longer valid to pass its address to this function. If this parameter is zero, then the result is the same aspxlast()
. This ensures the invariant
pxlast(p, pxnext(p, e)) == e
Return value
0
: There are no more elements
!0
: Points to previously allocated elementLibrary
- POOL.LIB
See Also
- pool_xinit, pool_link, pxalloc, pxfree, pxlast, pxnext
Dynamic C Functions | << Previous | Next >> | rabbit.com |