adapted to new list api.

This commit is contained in:
Gatsby Van
2023-12-23 17:01:58 +08:00
parent d746215628
commit 6ab4293c76
2 changed files with 32 additions and 10 deletions
+18 -6
View File
@@ -45,11 +45,23 @@ static void entry_free(void* val){
/** /**
* @brief helper function to match node entries by nodeIds * @brief helper function to match node entries by nodeIds
*/ */
static bool entry_match(void* a, void* b){ static int8_t entry_compare(void* a, void* b){
ASSERT(a != NULL); ASSERT(a != NULL);
ASSERT(b != NULL); ASSERT(b != NULL);
return (((NODE_ENTRY*)a)->nodeInfo.nodeId register uint8_t idA, idB;
== ((NODE_ENTRY*)b)->nodeInfo.nodeId); idA = ((NODE_ENTRY*)a)->nodeInfo.nodeId;
idB = ((NODE_ENTRY*)b)->nodeInfo.nodeId;
if (idA == idB)
{
return 0;
}
else if(idA < idB) {
return -1;
}
else {
return 1;
}
} }
/*****************************************************************************/ /*****************************************************************************/
/** /**
@@ -67,7 +79,7 @@ int32_t L2_NodeList_Init(NODE_LIST **list) {
return ENOMEM; return ENOMEM;
} }
(*list)->free = entry_free; (*list)->free = entry_free;
(*list)->match = entry_match; (*list)->compare = entry_compare;
return SUCCESS; return SUCCESS;
} }
@@ -98,7 +110,7 @@ void L2_NodeList_Destroy(NODE_LIST *list){
} }
/*****************************************************************************/ /*****************************************************************************/
/** /**
* @brief Get node entry frome node list base on node id. * @brief Get node entry from node list base on node id.
* *
* @param list * @param list
* @param nodeId * @param nodeId
@@ -334,7 +346,7 @@ int32_t L2_GetNodeSpeed(NODE_LIST *list, uint8_t nodeId, COORD *speed) {
* *
* @param list * @param list
* @param nodeId * @param nodeId
* @param defl * @param devi
* *
* @return SUCCESS update successfully. * @return SUCCESS update successfully.
* FAILURE Node not exist. * FAILURE Node not exist.
+14 -4
View File
@@ -40,11 +40,21 @@ static void schdevent_free(void* val){
/** /**
* @brief helper function to match events by ids. * @brief helper function to match events by ids.
*/ */
static bool schdevent_match(void* a, void* b){ static int8_t schdevent_compare(void* a, void* b){
ASSERT(a == NULL); ASSERT(a == NULL);
ASSERT(b != NULL); ASSERT(b != NULL);
return (((L2_SCHD_EVENT*)a)->eventId register uint32_t idA, idB;
== ((L2_SCHD_EVENT*)b)->eventId); idA = ((L2_SCHD_EVENT*)a)->eventId;
idB = ((L2_SCHD_EVENT*)b)->eventId;
if( idA== idB) {
return 0;
}
else if (idA < idB) {
return -1;
}
else {
return 1;
}
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -69,7 +79,7 @@ int32_t L2_CreateSchedEventPool(L2_SCHD_POOL** schdPool) {
return EALLOC; return EALLOC;
} }
(*schdPool)->schdList->free = schdevent_free; (*schdPool)->schdList->free = schdevent_free;
(*schdPool)->schdList->match = schdevent_match; (*schdPool)->schdList->compare = schdevent_compare;
(*schdPool)->envCnt = 0; (*schdPool)->envCnt = 0;
return SUCCESS; return SUCCESS;
} }