list -> clist to avoid naming conflict.

This commit is contained in:
Gatsby Van
2024-01-21 14:43:36 +08:00
parent 162e291533
commit 61a3c49ce8
6 changed files with 38 additions and 38 deletions
+18 -18
View File
@@ -21,7 +21,7 @@
#include <stdbool.h>
#include "linklayer814_types.h"
#include "node_list.h"
#include "../util/list.h"
#include "../util/clist.h"
#include "../common.h"
#include "../error.h"
@@ -79,7 +79,7 @@ static int8_t entry_compare(void *a, void *b)
******************************************************************************/
int32_t L2_NodeList_Init(NODE_LIST **list)
{
(*list) = list_new();
(*list) = clist_new();
if (*list == NULL)
{
return ENOMEM;
@@ -100,7 +100,7 @@ int32_t L2_NodeList_Init(NODE_LIST **list)
void L2_NodeList_Clear(NODE_LIST *list)
{
ASSERT(list != NULL);
list_clear(list);
clist_clear(list);
}
/*****************************************************************************/
@@ -114,7 +114,7 @@ void L2_NodeList_Clear(NODE_LIST *list)
******************************************************************************/
void L2_NodeList_Destroy(NODE_LIST *list)
{
list_destroy(list);
clist_destroy(list);
}
/*****************************************************************************/
/**
@@ -131,7 +131,7 @@ NODE_ENTRY *L2_GetNodeById(NODE_LIST *list, uint8_t nodeId)
{
ASSERT(list != NULL);
util_entry.nodeInfo.nodeId = nodeId;
list_node_t *node = list_find(list, &util_entry);
clist_node_t *node = clist_find(list, &util_entry);
if (node == NULL)
{
return NULL;
@@ -169,7 +169,7 @@ NODE_ENTRY *L2_AppendNode(NODE_LIST *list, uint8_t nodeId, L2_NODE_TYPE nodeType
DBG_ERROR("Failed to allocated memory for nodeEntry.\n");
return NULL;
}
list_node_t *node = list_node_new(nodeEntry);
clist_node_t *node = clist_node_new(nodeEntry);
if (node == NULL)
{
DBG_ERROR("Failed to allocated memory for list node.\n");
@@ -186,7 +186,7 @@ NODE_ENTRY *L2_AppendNode(NODE_LIST *list, uint8_t nodeId, L2_NODE_TYPE nodeType
nodeEntry->nodeInfo.speed.z = 0;
nodeEntry->nodeInfo.beamNo = 0;
nodeEntry->ttlCnt = 0;
list_rpush(list, node);
clist_rpush(list, node);
return nodeEntry;
}
@@ -205,14 +205,14 @@ int32_t L2_DeleteNodeById(NODE_LIST *list, uint8_t nodeId)
{
ASSERT(list != NULL);
util_entry.nodeInfo.nodeId = nodeId;
list_node_t *node = list_find(list, &util_entry);
clist_node_t *node = clist_find(list, &util_entry);
if (node == NULL)
{
DBG_WARNING("Node [%d] in not in node list, skip deleting process.\n", nodeId);
return SUCCESS;
}
DBG_INFO("Deleting node [%d].\n", nodeId);
list_remove(list, node);
clist_remove(list, node);
return SUCCESS;
}
@@ -490,14 +490,14 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
{
ASSERT(list != NULL);
int32_t Status;
list_node_t *node;
list_iterator_t *iter = list_iterator_new(list, LIST_HEAD);
clist_node_t *node;
clist_iterator_t *iter = clist_iterator_new(list, LIST_HEAD);
if (iter == NULL)
{
DBG_ERROR("Failed to initialize list iteration process.\n");
return EALLOC;
}
while ((node = list_iterator_next(iter)))
while ((node = clist_iterator_next(iter)))
{
Status = operation((NODE_ENTRY *)node->val, param);
if (Status != SUCCESS)
@@ -506,7 +506,7 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
break;
}
}
list_iterator_destroy(iter);
clist_iterator_destroy(iter);
return Status;
}
@@ -524,20 +524,20 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
int32_t L2_IterDeleteNode(NODE_LIST *list, bool (*condition)(NODE_ENTRY *))
{
ASSERT(list != NULL);
list_node_t *node;
list_iterator_t *iter = list_iterator_new(list, LIST_HEAD);
clist_node_t *node;
clist_iterator_t *iter = clist_iterator_new(list, LIST_HEAD);
if (iter == NULL)
{
DBG_ERROR("Failed to initialize list iteration process.\n");
return EALLOC;
}
while ((node = list_iterator_next(iter)))
while ((node = clist_iterator_next(iter)))
{
if (condition((NODE_ENTRY *)node->val) == false)
{
list_remove(list, node);
clist_remove(list, node);
}
}
list_iterator_destroy(iter);
clist_iterator_destroy(iter);
return SUCCESS;
}