List module implementation file. More...
Go to the source code of this file.
Functions | |
mcl_error_t | mcl_list_initialize (mcl_list_t **list) |
mcl_error_t | mcl_list_add (mcl_list_t *list, void *data) |
mcl_error_t | mcl_list_next (mcl_list_t *list, mcl_list_node_t **node) |
mcl_error_t | mcl_list_remove (mcl_list_t *list, mcl_list_node_t *node) |
mcl_error_t | mcl_list_remove_with_content (mcl_list_t *list, mcl_list_node_t *node, mcl_list_item_destroy_callback callback) |
mcl_error_t | mcl_list_exist (mcl_list_t *list, const void *item_to_find, mcl_list_compare_callback compare_function, void **item) |
void | mcl_list_reset (mcl_list_t *list) |
void | mcl_list_destroy (mcl_list_t **list) |
void | mcl_list_destroy_with_content (mcl_list_t **list, mcl_list_item_destroy_callback callback) |
List module implementation file.
Definition in file list.c.
mcl_error_t mcl_list_add | ( | mcl_list_t * | list, |
void * | data | ||
) |
This function adds a new item to list.
A new list item pointed by data
is added to the list. No new memory is allocated and no memory copy operations done. The lifetime of data
should be handled by the caller of this function.
[in] | list | The list to which the data is added. |
[in] | data | The pointer to the list item to be added. |
list
is full and data
can not be added to list
. Definition at line 34 of file list.c.
References mcl_list_t::count, mcl_list_t::current, mcl_list_node_t::data, mcl_list_t::head, mcl_list_t::last, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_LIMIT_EXCEEDED, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_SIZE_MAX, MCL_VERBOSE, mcl_list_node_t::next, and mcl_list_node_t::prev.
Referenced by _response_header_callback(), get_response(), mcl_http_client_add_certificate(), and mcl_http_request_add_header().
void mcl_list_destroy | ( | mcl_list_t ** | list | ) |
This function destroys the list.
For every node in the list, it frees the node but not the data it holds. After all nodes freed, it frees the list itself and sets it's value to NULL.
User needs to free all the data that the list is holding before destroying it!
[in] | list | The address of the pointer of the list to be destroyed. |
Definition at line 293 of file list.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_list_destroy_with_content(), and MCL_NULL.
void mcl_list_destroy_with_content | ( | mcl_list_t ** | list, |
mcl_list_item_destroy_callback | callback | ||
) |
This function destroys the list and its items with a given callback function.
For every node in the list, it frees the node. The data of the node can also freed by given callback function. After all nodes freed, it frees the list itself and sets it's value to NULL.
[in] | list | The address of the pointer of the list to be destroyed. |
[in] | callback | The callback function to destroy each node data within the list. If NULL no action will be performed. |
Definition at line 302 of file list.c.
References mcl_list_node_t::data, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_NULL, MCL_VERBOSE, and mcl_list_node_t::next.
Referenced by get_response(), mcl_http_client_destroy(), mcl_http_client_send(), mcl_http_request_destroy(), mcl_http_response_destroy(), and mcl_list_destroy().
mcl_error_t mcl_list_exist | ( | mcl_list_t * | list, |
const void * | item_to_find, | ||
mcl_list_compare_callback | compare_function, | ||
void ** | item | ||
) |
This function searches item_to_find
in the list
.
[in] | list | The list to search in. |
[in] | item_to_find | Item to search for. |
[in] | compare_function | Callback function used to compare. |
[out] | item | Pointer to the item found. |
item_to_find
exists in the list
. item_to_find
doesn't exist in the list
. Definition at line 239 of file list.c.
References mcl_list_node_t::data, mcl_list_t::head, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FUNCTION_LEAVE_LABEL, MCL_NULL, MCL_OK, and mcl_list_node_t::next.
mcl_error_t mcl_list_initialize | ( | mcl_list_t ** | list | ) |
This function initializes a list with zero items in it.
[out] | list | Initialized mcl_list_t instance. |
Definition at line 13 of file list.c.
References MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_NEW, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.
Referenced by get_response(), mcl_http_client_initialize(), mcl_http_client_send(), and mcl_http_request_initialize().
mcl_error_t mcl_list_next | ( | mcl_list_t * | list, |
mcl_list_node_t ** | node | ||
) |
This function gets the next node from the list.
Last returned node is kept in list. This function can be called consequently to loop over the list. If there is no node left to return or the list is empty, node
will be NULL.
[in] | list | The list. |
[out] | node | Address of next node. |
list
. Definition at line 76 of file list.c.
References mcl_list_t::current, mcl_list_t::head, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FUNCTION_LEAVE_LABEL, MCL_NULL, MCL_OK, and mcl_list_node_t::next.
Referenced by _ssl_context_callback(), mcl_http_response_get_header(), and send_header_list().
mcl_error_t mcl_list_remove | ( | mcl_list_t * | list, |
mcl_list_node_t * | node | ||
) |
This function removes a node from the list.
The list node is removed from the list and its handle of type mcl_list_node_t will be freed but the data that it holds will not. User needs to free the resource before it calls remove!
[in] | list | The list from which the node is removed. |
[in] | node | The node to be removed. |
list
is empty. Definition at line 117 of file list.c.
References mcl_list_t::count, mcl_list_t::current, mcl_list_t::head, mcl_list_t::last, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_FUNCTION_LEAVE_LABEL, MCL_LIST_IS_EMPTY, MCL_NULL, MCL_OK, MCL_VERBOSE, mcl_list_node_t::next, and mcl_list_node_t::prev.
Referenced by mcl_list_remove_with_content().
mcl_error_t mcl_list_remove_with_content | ( | mcl_list_t * | list, |
mcl_list_node_t * | node, | ||
mcl_list_item_destroy_callback | callback | ||
) |
This function removes a node from the list and destroys the removed item with the provided callback function.
The node (mcl_list_node_t) will be freed and the data that it holds is going to be destroyed by passing it to the provided callback function.
[in] | list | The list from which the node is removed. |
[in] | node | The node to be removed. |
[in] | callback | The callback function to destroy the list item. |
list
is empty. Definition at line 214 of file list.c.
References mcl_list_node_t::data, MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, mcl_list_remove(), MCL_NULL, and MCL_OK.
void mcl_list_reset | ( | mcl_list_t * | list | ) |
This function resets the current node to head node.
The goal here is to be able to loop over the list from it's beginning.
[in] | list | The list which is used to reset it's current node to it's head node. |
Definition at line 276 of file list.c.
References mcl_list_t::current, mcl_list_t::head, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_NULL, and MCL_VERBOSE.
Referenced by _set_request_options(), _ssl_context_callback(), mcl_http_response_get_header(), and send_header_list().