Difference between pages "r6:Function:slist get user data from element" and "r6:Function:slist new"
(Difference between pages)
Jump to navigation
Jump to search
m (1 revision imported) |
m (1 revision imported) |
||
Line 1: | Line 1: | ||
==Source Files== | ==Source Files== | ||
/src/slist/ | /src/slist/slist_new.c | ||
/inc/liblfds.h | /inc/liblfds.h | ||
==Prototype== | ==Prototype== | ||
int | int slist_new( struct slist_state **ss, | ||
void (*user_data_delete_function)(void *user_data, void *user_state), | |||
void *user_state ); | |||
==Parameters== | ==Parameters== | ||
''struct | ''struct slist_state **ss'' | ||
: A pointer to an slist | : A pointer to a pointer onto which is allocated the state which represents an slist. Set to NULL if slist creation fails. | ||
''void **user_data'' | ''void (*user_data_delete_function)(void *user_data, void *user_state)'' | ||
: A pointer to | : A callback function, which can be NULL. This function is called with the user data void pointer from each element after that element is logically deleted, giving the user an opportunity to delete any allocated state. | ||
''void *user_state'' | |||
: This is passed to each call of ''user_data_delete_function'' as the second argument to that function. The user is expected to use this to pass state information into his delete function. | |||
==Return Value== | ==Return Value== | ||
Returns 1 on | Returns 1 on successful list creation, 0 otherwise. On failure, ''*ss'' will also be set to NULL. | ||
==Notes== | ==Notes== | ||
This function | This function instantiates a slist. The values of ''user_data_delete_function'' and ''user_state'' are stored in the slist state for later use by ''[[r6:Function:slist_delete|slist_delete]]'', ''[[r6:Function:slist_delete_element|slist_delete_element]]'' and ''[[r6:Function:slist_delete_all_elements|slist_delete_all_elements]]''. | ||
==See Also== | ==See Also== | ||
* [[r6:API:SList|SList]] | * [[r6:API:SList|SList]] | ||
* [[r6:Function: | * [[r6:Function:slist_delete|slist_delete]] |
Latest revision as of 14:07, 4 January 2015
Source Files
/src/slist/slist_new.c /inc/liblfds.h
Prototype
int slist_new( struct slist_state **ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state );
Parameters
struct slist_state **ss
- A pointer to a pointer onto which is allocated the state which represents an slist. Set to NULL if slist creation fails.
void (*user_data_delete_function)(void *user_data, void *user_state)
- A callback function, which can be NULL. This function is called with the user data void pointer from each element after that element is logically deleted, giving the user an opportunity to delete any allocated state.
void *user_state
- This is passed to each call of user_data_delete_function as the second argument to that function. The user is expected to use this to pass state information into his delete function.
Return Value
Returns 1 on successful list creation, 0 otherwise. On failure, *ss will also be set to NULL.
Notes
This function instantiates a slist. The values of user_data_delete_function and user_state are stored in the slist state for later use by slist_delete, slist_delete_element and slist_delete_all_elements.