List module implementation file. More...
Go to the source code of this file.
Functions | |
E_MCL_ERROR_CODE | mcl_list_initialize (mcl_list_t **list) |
Initializes a list with zero items in it. More... | |
E_MCL_ERROR_CODE | mcl_list_add (mcl_list_t *list, void *data) |
Adds a new item to list. More... | |
E_MCL_ERROR_CODE | mcl_list_next (mcl_list_t *list, mcl_list_node_t **node) |
Gets the next node from the list. More... | |
E_MCL_ERROR_CODE | mcl_list_remove (mcl_list_t *list, mcl_list_node_t *node) |
Removes a node from the list. More... | |
E_MCL_ERROR_CODE | mcl_list_remove_with_content (mcl_list_t *list, mcl_list_node_t *node, mcl_list_item_destroy_callback callback) |
Removes a node from the list and destroys the removed item with the provided callback function. More... | |
E_MCL_ERROR_CODE | mcl_list_exist (mcl_list_t *list, const void *item_to_find, mcl_list_compare_callback compare_function, void **item) |
Searches item_to_find in the list . More... | |
void | mcl_list_reset (mcl_list_t *list) |
Reset the current node to head node. More... | |
void | mcl_list_destroy (mcl_list_t **list) |
Destroys the list. More... | |
void | mcl_list_destroy_with_content (mcl_list_t **list, mcl_list_item_destroy_callback callback) |
Destroys the list and its items with a given callback function. More... | |
E_MCL_ERROR_CODE | list_initialize (list_t **list) |
Initializes the list. More... | |
E_MCL_ERROR_CODE | list_add (list_t *list, void *data) |
Adds a new list item. More... | |
E_MCL_ERROR_CODE | list_remove_with_content (list_t *list, list_node_t *node, list_item_destroy_callback callback) |
Removes a node from the list and destroys the removed item with the provided callback function. More... | |
E_MCL_ERROR_CODE | list_remove (list_t *list, list_node_t *node) |
Removes a node from the list. More... | |
list_node_t * | list_next (list_t *list) |
Get the next node from the list. More... | |
void | list_reset (list_t *list) |
Reset the current node to head node. More... | |
E_MCL_ERROR_CODE | list_exist (list_t *list, const void *item_to_find, list_compare_callback compare_function, void **item) |
Searches item_to_find in the list . More... | |
void | list_destroy_with_content (list_t **list, list_item_destroy_callback callback) |
To destroy the list and its items with a given callback function. More... | |
void | list_destroy (list_t **list) |
To destroy the list. More... | |
List module implementation file.
Definition in file list.c.
E_MCL_ERROR_CODE list_add | ( | list_t * | list, |
void * | data | ||
) |
Adds a new list item.
The received data pointer is added to the list. No new memory is allocated and no memory copy operations done. The lifetime of the data
should be handled by the user.
[in] | list | The list to which the data is added. |
[in] | data | The data to be added. Only data pointer will be kept in the list. No additional memory operation will perform. |
list
is full and data
can not be added to list
. Definition at line 159 of file list.c.
References ASSERT_CODE_MESSAGE, mcl_list_t::count, mcl_list_t::current, mcl_list_node_t::data, mcl_list_t::head, mcl_list_t::last, MCL_LIMIT_EXCEEDED, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_SIZE_MAX, MCL_VERBOSE, mcl_list_node_t::next, mcl_list_node_t::prev, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _store_add_data(), event_list_add_event(), mcl_data_source_configuration_add_data_point(), mcl_data_source_configuration_add_data_source(), mcl_list_add(), mcl_time_series_add_value(), mcl_time_series_new_value_set(), and string_split().
void list_destroy | ( | list_t ** | list | ) |
To destroy 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 as 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 409 of file list.c.
References list_destroy_with_content(), MCL_NULL, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by mcl_list_destroy().
void list_destroy_with_content | ( | list_t ** | list, |
list_item_destroy_callback | callback | ||
) |
To destroy 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 as 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 373 of file list.c.
References mcl_list_t::count, mcl_list_node_t::data, DEBUG_ENTRY, DEBUG_LEAVE, mcl_list_t::head, MCL_DEBUG, MCL_FREE, MCL_NULL, and mcl_list_node_t::next.
Referenced by _destroy_data_source(), _destroy_value_set(), data_source_configuration_destroy(), event_list_destroy(), http_response_get_header(), list_destroy(), mcl_list_destroy_with_content(), mcl_store_destroy(), string_split(), and time_series_destroy().
E_MCL_ERROR_CODE list_exist | ( | list_t * | list, |
const void * | item_to_find, | ||
list_compare_callback | compare_function, | ||
void ** | item | ||
) |
Searches item_to_find
in the list
.
[in] | list | To search in. |
[in] | item_to_find | To search for. |
[in] | compare_function | Callback function to compare. |
[out] | item | If item_to_find is found, then the node data where item_to_find exists returned with this parameter. |
Definition at line 346 of file list.c.
References mcl_list_node_t::data, DEBUG_ENTRY, DEBUG_LEAVE, mcl_list_t::head, MCL_FAIL, MCL_NULL, MCL_OK, and mcl_list_node_t::next.
Referenced by mcl_list_exist(), and mcl_store_new_event().
E_MCL_ERROR_CODE list_initialize | ( | list_t ** | list | ) |
Initializes the list.
Head, Last and Current pointers will be set to NULL. Count will be 0.
[out] | list | Will point to the initialized list_t object. |
Definition at line 139 of file list.c.
References ASSERT_CODE_MESSAGE, mcl_list_t::count, mcl_list_t::current, mcl_list_t::head, mcl_list_t::last, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _initialize_payload(), event_list_initialize(), mcl_data_source_configuration_add_data_source(), mcl_list_initialize(), mcl_store_initialize(), mcl_time_series_new_value_set(), string_split(), and time_series_initialize().
list_node_t* list_next | ( | list_t * | list | ) |
Get 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, this function returns NULL.
[in] | list | The list. |
Definition at line 309 of file list.c.
References ASSERT_MESSAGE, mcl_list_t::current, mcl_list_t::head, MCL_NULL, mcl_list_node_t::next, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _add_data_source_configuration_data_points(), _add_data_source_configuration_data_sources(), _add_event_list(), _add_time_series_payload_values_array(), _add_time_series_value_sets(), _exchange_clear_sent_data_from_store(), _exchange_update_store_state(), and mcl_list_next().
E_MCL_ERROR_CODE list_remove | ( | list_t * | list, |
list_node_t * | node | ||
) |
Removes a node from the list.
The node (list_node_t) will be freed but the data that it holds is not going to be freed. 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 214 of file list.c.
References ASSERT_CODE_MESSAGE, mcl_list_t::count, mcl_list_t::current, mcl_list_t::head, mcl_list_t::last, MCL_ARRAY_IS_EMPTY, MCL_FREE, MCL_NULL, MCL_OK, MCL_VERBOSE, mcl_list_node_t::next, mcl_list_node_t::prev, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by list_remove_with_content(), and mcl_list_remove().
E_MCL_ERROR_CODE list_remove_with_content | ( | list_t * | list, |
list_node_t * | node, | ||
list_item_destroy_callback | callback | ||
) |
Removes a node from the list and destroys the removed item with the provided callback function.
The node (list_node_t) will be freed and the data that it holds is going to be destroyed by passing to the provided callback function. 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. |
[in] | callback | The callback function to destroy the list item. |
list
is empty. Definition at line 195 of file list.c.
References mcl_list_node_t::data, DEBUG_ENTRY, DEBUG_LEAVE, list_remove(), MCL_NULL, and MCL_OK.
Referenced by mcl_list_remove_with_content(), and store_data_remove().
void list_reset | ( | list_t * | list | ) |
Reset 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 329 of file list.c.
References mcl_list_t::current, mcl_list_t::head, MCL_NULL, MCL_VERBOSE, VERBOSE_ENTRY, and VERBOSE_LEAVE.
Referenced by _add_data_source_configuration_data_points(), _add_data_source_configuration_data_sources(), _add_event_list(), _add_time_series_payload_values_array(), _add_time_series_value_sets(), _exchange_update_store_state(), and mcl_list_reset().
E_MCL_ERROR_CODE mcl_list_add | ( | mcl_list_t * | list, |
void * | data | ||
) |
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 32 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, and list_add().
void mcl_list_destroy | ( | mcl_list_t ** | list | ) |
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 121 of file list.c.
References DEBUG_ENTRY, DEBUG_LEAVE, and list_destroy().
void mcl_list_destroy_with_content | ( | mcl_list_t ** | list, |
mcl_list_item_destroy_callback | callback | ||
) |
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 130 of file list.c.
References DEBUG_ENTRY, DEBUG_LEAVE, and list_destroy_with_content().
E_MCL_ERROR_CODE mcl_list_exist | ( | mcl_list_t * | list, |
const void * | item_to_find, | ||
mcl_list_compare_callback | compare_function, | ||
void ** | item | ||
) |
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 96 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, and list_exist().
E_MCL_ERROR_CODE mcl_list_initialize | ( | mcl_list_t ** | list | ) |
Initializes a list with zero items in it.
[out] | list | Initialized mcl_list_t instance. |
Definition at line 19 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, and list_initialize().
E_MCL_ERROR_CODE mcl_list_next | ( | mcl_list_t * | list, |
mcl_list_node_t ** | node | ||
) |
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 46 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, list_next(), MCL_FAIL, MCL_NULL, and MCL_OK.
E_MCL_ERROR_CODE mcl_list_remove | ( | mcl_list_t * | list, |
mcl_list_node_t * | node | ||
) |
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 67 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, and list_remove().
E_MCL_ERROR_CODE mcl_list_remove_with_content | ( | mcl_list_t * | list, |
mcl_list_node_t * | node, | ||
mcl_list_item_destroy_callback | callback | ||
) |
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 81 of file list.c.
References ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, and list_remove_with_content().
void mcl_list_reset | ( | mcl_list_t * | list | ) |
Reset 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 112 of file list.c.
References DEBUG_ENTRY, DEBUG_LEAVE, and list_reset().