Indented using indent script. Corrected any C++ comments using the comment script.
This commit is contained in:
@@ -42,31 +42,36 @@
|
||||
/* list of devices */
|
||||
static OS_Keylist Device_List = NULL;
|
||||
|
||||
void objects_init(void)
|
||||
void objects_init(
|
||||
void)
|
||||
{
|
||||
if (!Device_List)
|
||||
Device_List = Keylist_Create();
|
||||
}
|
||||
|
||||
int objects_device_count(void)
|
||||
int objects_device_count(
|
||||
void)
|
||||
{
|
||||
objects_init();
|
||||
return Keylist_Count(Device_List);
|
||||
}
|
||||
|
||||
OBJECT_DEVICE_T *objects_device_data(int index)
|
||||
OBJECT_DEVICE_T *objects_device_data(
|
||||
int index)
|
||||
{
|
||||
objects_init();
|
||||
return Keylist_Data_Index(Device_List, index);
|
||||
}
|
||||
|
||||
OBJECT_DEVICE_T *objects_device_by_instance(uint32_t device_instance)
|
||||
OBJECT_DEVICE_T *objects_device_by_instance(
|
||||
uint32_t device_instance)
|
||||
{
|
||||
objects_init();
|
||||
return Keylist_Data(Device_List, device_instance);
|
||||
}
|
||||
|
||||
OBJECT_DEVICE_T *objects_device_new(uint32_t device_instance)
|
||||
OBJECT_DEVICE_T *objects_device_new(
|
||||
uint32_t device_instance)
|
||||
{
|
||||
OBJECT_DEVICE_T *pDevice = NULL;
|
||||
KEY key = device_instance;
|
||||
@@ -85,7 +90,8 @@ OBJECT_DEVICE_T *objects_device_new(uint32_t device_instance)
|
||||
pDevice->Object_List = Keylist_Create();
|
||||
Keylist_Data_Add(Device_List, key, pDevice);
|
||||
} else {
|
||||
fprintf(stderr,"Objects: Unable to allocate device %d buffer\n",
|
||||
fprintf(stderr,
|
||||
"Objects: Unable to allocate device %d buffer\n",
|
||||
device_instance);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +100,8 @@ OBJECT_DEVICE_T *objects_device_new(uint32_t device_instance)
|
||||
return pDevice;
|
||||
}
|
||||
|
||||
OBJECT_DEVICE_T *objects_device_delete(int index)
|
||||
OBJECT_DEVICE_T *objects_device_delete(
|
||||
int index)
|
||||
{
|
||||
OBJECT_DEVICE_T *pDevice = NULL;
|
||||
BACNET_OBJECT_ID *pObject;
|
||||
@@ -102,12 +109,12 @@ OBJECT_DEVICE_T *objects_device_delete(int index)
|
||||
if (Device_List) {
|
||||
pDevice = Keylist_Data_Delete_By_Index(Device_List, index);
|
||||
if (pDevice) {
|
||||
fprintf(stderr,"Objects: removing device %d",
|
||||
fprintf(stderr, "Objects: removing device %d",
|
||||
pDevice->Object_Identifier.instance);
|
||||
if (pDevice->Object_List) {
|
||||
do {
|
||||
pObject =
|
||||
Keylist_Data_Delete_By_Index(pDevice->Object_List,0);
|
||||
Keylist_Data_Delete_By_Index(pDevice->Object_List, 0);
|
||||
/* free any dynamic memory used */
|
||||
if (pObject) {
|
||||
free(pObject);
|
||||
@@ -130,7 +137,7 @@ OBJECT_DEVICE_T *objects_device_delete(int index)
|
||||
/* test the object creation and deletion */
|
||||
void testBACnetObjectsCompare(
|
||||
Test * pTest,
|
||||
OBJECT_DEVICE_T *pDevice,
|
||||
OBJECT_DEVICE_T * pDevice,
|
||||
uint32_t device_id)
|
||||
{
|
||||
ct_test(pTest, pDevice != NULL);
|
||||
@@ -150,28 +157,26 @@ void testBACnetObjects(
|
||||
const unsigned max_test_points = 20;
|
||||
OBJECT_DEVICE_T *pDevice;
|
||||
|
||||
for (test_point = 0;test_point < max_test_points;test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE/max_test_points);
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points);
|
||||
pDevice = objects_device_new(device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
pDevice = objects_device_by_instance(device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
}
|
||||
ct_test(pTest, max_test_points == objects_device_count());
|
||||
for (test_point = 0;test_point < max_test_points;test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE/max_test_points);
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points);
|
||||
pDevice = objects_device_by_instance(device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
testBACnetObjectsCompare(pTest, pDevice, device_id);
|
||||
}
|
||||
for (test_point = 0;test_point < max_test_points;test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE/max_test_points);
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points);
|
||||
pDevice = objects_device_data(test_point);
|
||||
testBACnetObjectsCompare(
|
||||
pTest,
|
||||
pDevice,
|
||||
Keylist_Key(Device_List, test_point));
|
||||
testBACnetObjectsCompare(pTest, pDevice, Keylist_Key(Device_List,
|
||||
test_point));
|
||||
}
|
||||
for (test_point = 0;test_point < max_test_points;test_point++) {
|
||||
for (test_point = 0; test_point < max_test_points; test_point++) {
|
||||
pDevice = objects_device_delete(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user