<< Previous | Next >>

pputlast

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

Description

Atomically remove allocated element "e" and re-insert it at the end of the allocated list. "Atomically" means that the POOL_IPSET level is used to lock out other CPU contexts from altering the pool while this operation is in progress.

This is equivalent to:

   

pmovebetween(p, e, plast(p), NULL);

but is considerably faster.

A common use for this function is to insert an element allocated when the POOL_LINKED_BY_APP attribute is set for the pool, at the end of the allocated list. This is useful when, say, an ISR allocates and uses a buffer without placing it on the allocated list. Only when the buffer is complete does the ISR use this function to place it on the queue for reading by the main application.

The pool MUST be set to being a linked pool by using:

   

pool_link(p, <non-zero>);

otherwise the results are undefined.

Parameters

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

e
Address of element to move. If NULL, then this function behaves as plast().

Return Value

Same as the "e" parameter, unless "e" is NULL in which case the existing last element is returned as per plast().

Library

POOL.LIB

See Also

pmovebetween, pool_link


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