update keylist to use bool and stdint value for key not found. (#572)
* Updated keylist to use bool and stdint value for key not found. * Added Keylist_Index_Key to deprecate Keylist_Key function * Changed the deprecated Keylist_Key API to Keylist_Index_Key * Added unit test for Keylist_Index_Key API
This commit is contained in:
@@ -156,7 +156,11 @@ unsigned Analog_Output_Count(void)
|
||||
*/
|
||||
uint32_t Analog_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,18 +159,20 @@ uint32_t bacfile_pathname_instance(
|
||||
struct object_data *pObject;
|
||||
int count = 0;
|
||||
int index = 0;
|
||||
KEY key = BACNET_MAX_INSTANCE;
|
||||
|
||||
count = Keylist_Count(Object_List);
|
||||
while (count) {
|
||||
pObject = Keylist_Data_Index(Object_List, index);
|
||||
if (strcmp(pathname, pObject->Pathname) == 0) {
|
||||
return Keylist_Key(Object_List, index);
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
break;
|
||||
}
|
||||
count--;
|
||||
index++;
|
||||
}
|
||||
|
||||
return BACNET_MAX_INSTANCE;
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +264,11 @@ uint32_t bacfile_count(void)
|
||||
*/
|
||||
uint32_t bacfile_index_to_instance(unsigned find_index)
|
||||
{
|
||||
return Keylist_Key(Object_List, find_index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, find_index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,7 +143,11 @@ unsigned Binary_Lighting_Output_Count(void)
|
||||
*/
|
||||
uint32_t Binary_Lighting_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,7 +159,11 @@ unsigned Binary_Output_Count(void)
|
||||
*/
|
||||
uint32_t Binary_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,7 +133,11 @@ unsigned Calendar_Count(void)
|
||||
*/
|
||||
uint32_t Calendar_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -154,7 +154,11 @@ unsigned Channel_Count(void)
|
||||
*/
|
||||
uint32_t Channel_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,7 +148,11 @@ unsigned Color_Count(void)
|
||||
*/
|
||||
uint32_t Color_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -144,7 +144,11 @@ unsigned Color_Temperature_Count(void)
|
||||
*/
|
||||
uint32_t Color_Temperature_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -174,7 +174,11 @@ unsigned Lighting_Output_Count(void)
|
||||
*/
|
||||
uint32_t Lighting_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,7 +133,11 @@ unsigned Life_Safety_Point_Count(void)
|
||||
*/
|
||||
uint32_t Life_Safety_Point_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,7 +150,11 @@ unsigned Multistate_Output_Count(void)
|
||||
*/
|
||||
uint32_t Multistate_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -136,7 +136,11 @@ unsigned Time_Value_Count(void)
|
||||
*/
|
||||
uint32_t Time_Value_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return Keylist_Key(Object_List, index);
|
||||
KEY key = UINT32_MAX;
|
||||
|
||||
Keylist_Index_Key(Object_List, index, &key);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user