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 <stdbool.h>
#include "linklayer814_types.h" #include "linklayer814_types.h"
#include "node_list.h" #include "node_list.h"
#include "../util/list.h" #include "../util/clist.h"
#include "../common.h" #include "../common.h"
#include "../error.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) int32_t L2_NodeList_Init(NODE_LIST **list)
{ {
(*list) = list_new(); (*list) = clist_new();
if (*list == NULL) if (*list == NULL)
{ {
return ENOMEM; return ENOMEM;
@@ -100,7 +100,7 @@ int32_t L2_NodeList_Init(NODE_LIST **list)
void L2_NodeList_Clear(NODE_LIST *list) void L2_NodeList_Clear(NODE_LIST *list)
{ {
ASSERT(list != NULL); 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) 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); ASSERT(list != NULL);
util_entry.nodeInfo.nodeId = nodeId; 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) if (node == NULL)
{ {
return 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"); DBG_ERROR("Failed to allocated memory for nodeEntry.\n");
return NULL; return NULL;
} }
list_node_t *node = list_node_new(nodeEntry); clist_node_t *node = clist_node_new(nodeEntry);
if (node == NULL) if (node == NULL)
{ {
DBG_ERROR("Failed to allocated memory for list node.\n"); 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.speed.z = 0;
nodeEntry->nodeInfo.beamNo = 0; nodeEntry->nodeInfo.beamNo = 0;
nodeEntry->ttlCnt = 0; nodeEntry->ttlCnt = 0;
list_rpush(list, node); clist_rpush(list, node);
return nodeEntry; return nodeEntry;
} }
@@ -205,14 +205,14 @@ int32_t L2_DeleteNodeById(NODE_LIST *list, uint8_t nodeId)
{ {
ASSERT(list != NULL); ASSERT(list != NULL);
util_entry.nodeInfo.nodeId = nodeId; 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) if (node == NULL)
{ {
DBG_WARNING("Node [%d] in not in node list, skip deleting process.\n", nodeId); DBG_WARNING("Node [%d] in not in node list, skip deleting process.\n", nodeId);
return SUCCESS; return SUCCESS;
} }
DBG_INFO("Deleting node [%d].\n", nodeId); DBG_INFO("Deleting node [%d].\n", nodeId);
list_remove(list, node); clist_remove(list, node);
return SUCCESS; return SUCCESS;
} }
@@ -490,14 +490,14 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
{ {
ASSERT(list != NULL); ASSERT(list != NULL);
int32_t Status; int32_t Status;
list_node_t *node; clist_node_t *node;
list_iterator_t *iter = list_iterator_new(list, LIST_HEAD); clist_iterator_t *iter = clist_iterator_new(list, LIST_HEAD);
if (iter == NULL) if (iter == NULL)
{ {
DBG_ERROR("Failed to initialize list iteration process.\n"); DBG_ERROR("Failed to initialize list iteration process.\n");
return EALLOC; return EALLOC;
} }
while ((node = list_iterator_next(iter))) while ((node = clist_iterator_next(iter)))
{ {
Status = operation((NODE_ENTRY *)node->val, param); Status = operation((NODE_ENTRY *)node->val, param);
if (Status != SUCCESS) if (Status != SUCCESS)
@@ -506,7 +506,7 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
break; break;
} }
} }
list_iterator_destroy(iter); clist_iterator_destroy(iter);
return Status; 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 *)) int32_t L2_IterDeleteNode(NODE_LIST *list, bool (*condition)(NODE_ENTRY *))
{ {
ASSERT(list != NULL); ASSERT(list != NULL);
list_node_t *node; clist_node_t *node;
list_iterator_t *iter = list_iterator_new(list, LIST_HEAD); clist_iterator_t *iter = clist_iterator_new(list, LIST_HEAD);
if (iter == NULL) if (iter == NULL)
{ {
DBG_ERROR("Failed to initialize list iteration process.\n"); DBG_ERROR("Failed to initialize list iteration process.\n");
return EALLOC; return EALLOC;
} }
while ((node = list_iterator_next(iter))) while ((node = clist_iterator_next(iter)))
{ {
if (condition((NODE_ENTRY *)node->val) == false) 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; return SUCCESS;
} }
+2 -2
View File
@@ -24,7 +24,7 @@
#include "linklayer814_types.h" #include "linklayer814_types.h"
#include "geometry/coord.h" #include "geometry/coord.h"
#include "../util/util.h" #include "../util/util.h"
#include "../util/list.h" #include "../util/clist.h"
/************************** Constant Definitions *****************************/ /************************** Constant Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
@@ -36,7 +36,7 @@ typedef struct NODE_LIST_ENTRY
int32_t timeDevi; int32_t timeDevi;
} NODE_ENTRY; } NODE_ENTRY;
typedef list_t NODE_LIST; typedef clist_t NODE_LIST;
/************************** Variable Definitions *****************************/ /************************** Variable Definitions *****************************/
+14 -14
View File
@@ -20,7 +20,7 @@
#include "linklayer814.h" #include "linklayer814.h"
#include "linklayer814_types.h" #include "linklayer814_types.h"
#include "../error.h" #include "../error.h"
#include "../util/list.h" #include "../util/clist.h"
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/************************** Variable Definitions *****************************/ /************************** Variable Definitions *****************************/
@@ -80,7 +80,7 @@ int32_t L2_CreateSchedEventPool(L2_SCHD_POOL **schdPool)
DBG_ERROR("Failed to allocated memory for schdPool.\n"); DBG_ERROR("Failed to allocated memory for schdPool.\n");
return EALLOC; return EALLOC;
} }
(*schdPool)->schdList = list_new(); (*schdPool)->schdList = clist_new();
if ((*schdPool)->schdList == NULL) if ((*schdPool)->schdList == NULL)
{ {
DBG_ERROR("Failed to allocated memory for schdPool->schdList.\n"); DBG_ERROR("Failed to allocated memory for schdPool->schdList.\n");
@@ -106,7 +106,7 @@ int32_t L2_CreateSchedEventPool(L2_SCHD_POOL **schdPool)
void L2_ClearSchedEventPool(L2_SCHD_POOL *schdPool) void L2_ClearSchedEventPool(L2_SCHD_POOL *schdPool)
{ {
ASSERT(schdPool != NULL); ASSERT(schdPool != NULL);
list_clear(schdPool->schdList); clist_clear(schdPool->schdList);
schdPool->envCnt = 0; schdPool->envCnt = 0;
} }
@@ -125,7 +125,7 @@ void L2_DestroySchedEventPool(L2_SCHD_POOL *schdPool)
{ {
return; return;
} }
list_destroy(schdPool->schdList); clist_destroy(schdPool->schdList);
free(schdPool); free(schdPool);
} }
@@ -155,7 +155,7 @@ L2_SCHD_EVENT *L2_CreatNewSchdEvent(L2_SCHD_POOL *schdPool, L2_EVENT_TYPE event,
DBG_ERROR("Failed to allocate schedule event.\n"); DBG_ERROR("Failed to allocate schedule event.\n");
return NULL; return NULL;
} }
list_node_t *node = list_node_new(schdEvent); clist_node_t *node = clist_node_new(schdEvent);
if (node == NULL) if (node == NULL)
{ {
DBG_ERROR("Failed to allocate schedule event list node.\n"); DBG_ERROR("Failed to allocate schedule event list node.\n");
@@ -170,7 +170,7 @@ L2_SCHD_EVENT *L2_CreatNewSchdEvent(L2_SCHD_POOL *schdPool, L2_EVENT_TYPE event,
schdEvent->isVolatile = isVolatile; schdEvent->isVolatile = isVolatile;
schdEvent->schdSlot = L2_SLOTNO_NONE; schdEvent->schdSlot = L2_SLOTNO_NONE;
schdEvent->schdFrame = L2_FRAMENO_NONE; schdEvent->schdFrame = L2_FRAMENO_NONE;
list_rpush(schdPool->schdList, node); clist_rpush(schdPool->schdList, node);
return schdEvent; return schdEvent;
} }
@@ -189,7 +189,7 @@ L2_SCHD_EVENT *L2_GetEventById(L2_SCHD_POOL *schdPool, uint32_t id)
{ {
ASSERT(schdPool != NULL); ASSERT(schdPool != NULL);
util_schdevent.eventId = id; util_schdevent.eventId = id;
list_node_t *node = list_find(schdPool->schdList, &util_schdevent); clist_node_t *node = clist_find(schdPool->schdList, &util_schdevent);
if (node != NULL) if (node != NULL)
{ {
DBG_WARNING("Event with id=%d, dose not exist.\n", id); DBG_WARNING("Event with id=%d, dose not exist.\n", id);
@@ -214,13 +214,13 @@ int32_t L2_DeleteSchdEventById(L2_SCHD_POOL *schdPool, uint32_t id)
{ {
ASSERT(schdPool != NULL); ASSERT(schdPool != NULL);
util_schdevent.eventId = id; util_schdevent.eventId = id;
list_node_t *node = list_find(schdPool->schdList, &util_schdevent); clist_node_t *node = clist_find(schdPool->schdList, &util_schdevent);
if (node != NULL) if (node != NULL)
{ {
DBG_ERROR("Event with id=%d, dose not exist.\n", id); DBG_ERROR("Event with id=%d, dose not exist.\n", id);
return EIGNORE; return EIGNORE;
} }
list_remove(schdPool->schdList, node); clist_remove(schdPool->schdList, node);
return SUCCESS; return SUCCESS;
} }
@@ -343,16 +343,16 @@ int32_t L2_RescheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint
void L2_EventPoolHandler(L2_INST *instPtr) void L2_EventPoolHandler(L2_INST *instPtr)
{ {
ASSERT(instPtr != NULL); ASSERT(instPtr != NULL);
list_node_t *node; clist_node_t *node;
L2_SCHD_EVENT *event; L2_SCHD_EVENT *event;
L2_SCHD_POOL *pool = instPtr->schdEventPool; L2_SCHD_POOL *pool = instPtr->schdEventPool;
list_iterator_t *iter = list_iterator_new(pool->schdList, LIST_HEAD); clist_iterator_t *iter = clist_iterator_new(pool->schdList, LIST_HEAD);
if (iter == NULL) if (iter == NULL)
{ {
DBG_ERROR("Failed to initialize schedule event pool iteration.\n"); DBG_ERROR("Failed to initialize schedule event pool iteration.\n");
return; return;
} }
while ((node = list_iterator_next(iter))) while ((node = clist_iterator_next(iter)))
{ {
event = (L2_SCHD_EVENT *)node->val; event = (L2_SCHD_EVENT *)node->val;
if (L2_isEventScheduled(event)) if (L2_isEventScheduled(event))
@@ -364,7 +364,7 @@ void L2_EventPoolHandler(L2_INST *instPtr)
if (event->isVolatile == true) if (event->isVolatile == true)
{ {
DBG_INFO("Deleting scheduled event [%d], since it is volatile.\n", event->eventId); DBG_INFO("Deleting scheduled event [%d], since it is volatile.\n", event->eventId);
list_remove(pool->schdList, node); clist_remove(pool->schdList, node);
} }
else else
{ {
@@ -373,7 +373,7 @@ void L2_EventPoolHandler(L2_INST *instPtr)
} }
} }
} }
list_iterator_destroy(iter); clist_iterator_destroy(iter);
} }
/*****************************************************************************/ /*****************************************************************************/
+2 -2
View File
@@ -21,7 +21,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "linklayer814_types.h" #include "linklayer814_types.h"
#include "../error.h" #include "../error.h"
#include "../util/list.h" #include "../util/clist.h"
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/** @name L2 event /** @name L2 event
@@ -43,7 +43,7 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
list_t *schdList; clist_t *schdList;
uint32_t envCnt; uint32_t envCnt;
} L2_SCHD_POOL; } L2_SCHD_POOL;
+1 -1
View File
@@ -13,7 +13,7 @@
// //
#include <stdint.h> #include <stdint.h>
#include "list.h" #include "clist.h"
/* /*
* Allocates a new clist_node_t. NULL on failure. * Allocates a new clist_node_t. NULL on failure.
+1 -1
View File
@@ -1,6 +1,6 @@
// //
// list.h // clist.h
// //
// Copyright (c) 2010 TJ Holowaychuk <[email protected]> // Copyright (c) 2010 TJ Holowaychuk <[email protected]>
// //