Name

list_init

Synopsis

void list_init(List *list, void (*destroy)(void *data));

Return Value

None.

Description

Initializes the linked list specified by list. This operation must be called for a linked list before the list can be used with any other operation. The destroy argument provides a way to free dynamically allocated data when list_destroy is called. For example, if the list contains data dynamically allocated using malloc, destroy should be set to free to free the data as the linked list is destroyed. For structured data containing several dynamically allocated members, destroy should be set to a user-defined function that calls free for each dynamically allocated member as well as for the structure itself. For a linked list containing data that should not be freed, destroy should be set to NULL.

Complexity

O (1)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset