list.h File Reference

List module header file. More...

#include "mcl/mcl_list.h"
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef mcl_list_node_t list_node_t
 
typedef mcl_list_t list_t
 
typedef mcl_list_compare_callback list_compare_callback
 
typedef mcl_list_item_destroy_callback list_item_destroy_callback
 

Functions

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 (list_t *list, list_node_t *node)
 Removes a node from the list. 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...
 
list_node_tlist_next (list_t *list)
 Get the next node from the list. 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_reset (list_t *list)
 Reset the current node to head node. More...
 
void list_destroy (list_t **list)
 To destroy 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...
 

Detailed Description

List module header file.


Date
Jul 20, 2016 This module is used for double linked list handling.

Definition in file list.h.

Typedef Documentation

Definition at line 23 of file list.h.

Definition at line 21 of file list.h.

typedef mcl_list_t list_t

Definition at line 22 of file list.h.

Function Documentation

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.

Parameters
[in]listThe list to which the data is added.
[in]dataThe data to be added. Only data pointer will be kept in the list. No additional memory operation will perform.
Returns

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().

Here is the caller graph for this function:

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!

Parameters
[in]listThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]listThe address of the pointer of the list to be destroyed.
[in]callbackThe 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().

Here is the caller graph for this function:

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.

Parameters
[in]listTo search in.
[in]item_to_findTo search for.
[in]compare_functionCallback function to compare.
[out]itemIf item_to_find is found, then the node data where item_to_find exists returned with this parameter.
Returns
  • MCL_OK if item_to_find exists in the list.
  • MCL_FAIL if item_to_find doesn't exist in the list.

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().

Here is the caller graph for this function:

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.

Parameters
[out]listWill point to the initialized list_t object.
Returns

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().

Here is the caller graph for this function:

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.

Parameters
[in]listThe list.
Returns
The next node in 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().

Here is the caller graph for this function:

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!

Parameters
[in]listThe list from which the node is removed.
[in]nodeThe node to be removed.
Returns

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().

Here is the caller graph for this function:

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!

Parameters
[in]listThe list from which the node is removed.
[in]nodeThe node to be removed.
[in]callbackThe callback function to destroy the list item.
Returns

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]listThe 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().

Here is the caller graph for this function: