r6.1.0:lfds610_freelist_new_elements

From liblfds.org
Revision as of 14:07, 4 January 2015 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source Files

/liblfds610/src/lfds610_freelist/lfds610_freelist_new.c
/liblfds610/inc/liblfds610.h

Prototype

lfds610_atom_t lfds610_freelist_new_elements( struct lfds610_freelist_state *fs, lfds610_atom_t number_elements );

Parameters

struct lfds610_freelist_state *fs

A freelist state as allocated by lfds610_freelist_new.

lfds610_atom_t number_elements

The number of additional elements to add to the freelist.

Return Value

The number of elements added to the freelist.

Notes

This function creates a new freelist element and adds it to the freelist, repeating this process number_elements times. Each element will be passed to the user_data_init_function function passed into the lfds610_freelist_new function. That function will also be passed the user_state argument which was provided to lfds610_freelist_new. If element creation fails (will can be only due to memory allocation failure or failure of the user initialisation function), that element will not be created and so the number of elements actually added to the freelist will be less than the requested number.

This function is thread-safe; it can be used in parallel with other functions adding new elements and with pushing and popping.

See Also