Added object-name c-string getter function to basic objects so they can be referenced to free if dynamically created. (#754)

* Added basic object-name get for ASCII names to enable free if they were dynamically created. Added unit testing to validate the basic object ASCII object-name API.

* Removed static scope on character array used for name since the array gets copied into characterstring array and static is not needed.
This commit is contained in:
Steve Karg
2024-08-28 16:21:58 -05:00
committed by GitHub
parent b3c8c10c03
commit 3d3e192ae9
86 changed files with 872 additions and 87 deletions
+21 -2
View File
@@ -33,7 +33,7 @@
#define FILE_RECORD_SIZE MAX_OCTET_STRING_BYTES
#endif
struct object_data {
char *Object_Name;
const char *Object_Name;
char *Pathname;
BACNET_DATE_TIME Modification_Date;
char *File_Type;
@@ -206,7 +206,7 @@ bool bacfile_object_name_set(uint32_t object_instance, char *new_name)
struct object_data *pObject;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject && new_name) {
if (pObject) {
status = true;
pObject->Object_Name = new_name;
}
@@ -214,6 +214,25 @@ bool bacfile_object_name_set(uint32_t object_instance, char *new_name)
return status;
}
/**
* @brief Return the object name C string
* @param object_instance [in] BACnet object instance number
* @return object name or NULL if not found
*/
const char *bacfile_name_ansi(uint32_t object_instance)
{
const char *name = NULL;
struct object_data *pObject;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
name = pObject->Object_Name;
}
return name;
}
/**
* @brief Determines if a given object instance is valid
* @param object_instance - object-instance number of the object