34 DEBUG_ENTRY(
"mcl_list_t *list = <%p>, void *data = <%p>", list, data)
69 DEBUG_ENTRY(
"mcl_list_t *list = <%p>, mcl_list_node_t *node = <%p>", list, node)
83 DEBUG_ENTRY(
"mcl_list_t *list = <%p>, mcl_list_node_t *node = <%p>, mcl_list_item_destroy_callback callback = <%p>", list, node, &callback)
98 DEBUG_ENTRY(
"mcl_list_t *list = <%p>, const void *item_to_find = <%p>, mcl_list_compare_callback compare_function = <%p>, void **item = <%p>", list, item_to_find, &compare_function, item)
106 code =
list_exist(list, item_to_find, compare_function, item);
132 DEBUG_ENTRY(
"mcl_list_t **list = <%p>, mcl_list_item_destroy_callback callback = <%p>", list, &callback);
150 list_local->
count = 0;
161 VERBOSE_ENTRY(
"list_t *list = <%p>, void *data = <%p>", list, data)
169 new_node->
data = data;
172 MCL_VERBOSE(
"new_node initialized and its data assigned to the received one. Node's data address = <%p>", (
void *)new_node->
data);
174 if (0 == list->
count)
176 MCL_VERBOSE(
"This is the first node in the list.");
177 list->
head = new_node;
178 list->
last = new_node;
184 list->
last = new_node;
189 MCL_VERBOSE(
"new_node has been added to the list. Current list count = <%d>", list->
count);
197 DEBUG_ENTRY(
"list_t *list = <%p>, list_node_t *node = <%p>, list_item_destroy_callback callback = <%p>", list, node, callback)
200 void *data = node->
data;
216 VERBOSE_ENTRY(
"list_t *list = <%p>, list_node_t *node = <%p>", list, node)
233 MCL_VERBOSE(
"This is the only node in list. No need for any connection handling.");
241 MCL_VERBOSE(
"There is node's after this node. Next node's prev is set NULL.");
257 MCL_VERBOSE(
"This is the last node. Previous node's next is set NULL");
265 MCL_VERBOSE(
"node->next and node->prev are not MCL_NULL.");
266 MCL_VERBOSE(
"This is a middle node. prev's next is connected to current next. next's prev is connected to current prev.");
274 if (list->
head == node)
278 MCL_VERBOSE(
"This is the head node. Head pointer updated to the next node");
281 if (list->
last == node)
285 MCL_VERBOSE(
"This is the last node. Last pointer updated to the previous node");
292 MCL_VERBOSE(
"This is the list's current node. Current pointer updated to the next node");
297 MCL_VERBOSE(
"List counter decreased by one. Current count = <%d>", list->
count);
348 DEBUG_ENTRY(
"list_t *list = <%p>, const void *item_to_find = <%p>, list_compare_callback compare_function = <%p>, void **item = <%p>", list, item_to_find,
349 &compare_function, item)
357 if (
MCL_OK == item_exists_in_the_list)
359 *item = current_node->
data;
365 current_node = current_node->
next;
375 DEBUG_ENTRY(
"list_t **list = <%p>, list_item_destroy_callback callback = <%p>", list, &callback)
377 list_t *local_list = *list;
393 callback(&(current_node->
data));
396 node_to_free = current_node;
397 current_node = node_to_free->
next;
399 MCL_DEBUG(
"%d. node has been freed..", index++);
Memory module header file.
#define VERBOSE_LEAVE(...)
void list_reset(list_t *list)
Reset the current node to head node.
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...
E_MCL_ERROR_CODE mcl_list_next(mcl_list_t *list, mcl_list_node_t **node)
Gets the next node from the list.
#define ASSERT_MESSAGE(condition,...)
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.
void(* mcl_list_item_destroy_callback)(void **item)
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.
mcl_list_compare_callback list_compare_callback
#define ASSERT_NOT_NULL(argument)
Log utility module header file.
E_MCL_ERROR_CODE list_initialize(list_t **list)
Initializes the list.
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.
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
E_MCL_ERROR_CODE mcl_list_add(mcl_list_t *list, void *data)
Adds a new item to list.
void list_destroy(list_t **list)
To destroy the list.
#define VERBOSE_ENTRY(...)
struct mcl_list_node_t * next
Next node in the list.
mcl_list_node_t * head
Head node of the list.
void mcl_list_reset(mcl_list_t *list)
Reset the current node to head node.
E_MCL_ERROR_CODE list_remove(list_t *list, list_node_t *node)
Removes a node from the list.
There is no element in the array.
#define ASSERT_CODE_MESSAGE(condition, return_code,...)
Definitions module header file.
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...
list_node_t * list_next(list_t *list)
Get the next node from the list.
struct mcl_list_node_t * prev
Previous node in the list.
mcl_list_node_t * last
Last node of the list.
No more space is left to add an additional object.
void mcl_list_destroy(mcl_list_t **list)
Destroys the list.
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.
E_MCL_ERROR_CODE mcl_list_initialize(mcl_list_t **list)
Initializes a list with zero items in it.
mcl_list_node_t * current
Current node of the list.
E_MCL_ERROR_CODE(* mcl_list_compare_callback)(void *reference_item, const void *item_to_compare)
E_MCL_ERROR_CODE mcl_list_remove(mcl_list_t *list, mcl_list_node_t *node)
Removes a node from the list.
mcl_size_t count
Node count of the list.
E_MCL_ERROR_CODE list_add(list_t *list, void *data)
Adds a new list item.
mcl_list_item_destroy_callback list_item_destroy_callback
void * data
Data of the node.