<< Previous | Next >>

pprev

void * pprev( Pool_t * p, void * e );

Description

Get the previously 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 = plast(p); e; e = pprev(p, e)) {
...
}

Parameters

p
Pool handle structure, as previously passed to pool_init().

e
Previous element address, obtained by, e.g., plast(). 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 using pfree(): 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 plast(). This ensures the invariant

pprev(p, pnext(p, e)) == e

Return value

 null: There are no more elements
!null: Pointer to previous allocated element

Library

POOL.LIB

See Also

pool_init, pool_link, palloc, pfree, plast, pnext


Dynamic C Functions << Previous | Next >> rabbit.com