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
*/
static bool entry_match(void* a, void* b){
static int8_t entry_compare(void* a, void* b){
ASSERT(a != NULL);
ASSERT(b != NULL);
return (((NODE_ENTRY*)a)->nodeInfo.nodeId
== ((NODE_ENTRY*)b)->nodeInfo.nodeId);
register uint8_t idA, idB;
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;
}
(*list)->free = entry_free;
(*list)->match = entry_match;
(*list)->compare = entry_compare;
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 nodeId
@@ -334,7 +346,7 @@ int32_t L2_GetNodeSpeed(NODE_LIST *list, uint8_t nodeId, COORD *speed) {
*
* @param list
* @param nodeId
* @param defl
* @param devi
*
* @return SUCCESS update successfully.
* FAILURE Node not exist.