From 855b7dfc99e2785272e8668b917dbafa7a175104 Mon Sep 17 00:00:00 2001 From: Nicola <61830443+nicola02nb@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:46:41 +0100 Subject: [PATCH] Added comment to find_devices(), moved DeviceListNode to device.h --- src/device.h | 11 +++++++++++ src/main.c | 15 ++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/device.h b/src/device.h index 71f6f60..f8f49b1 100644 --- a/src/device.h +++ b/src/device.h @@ -394,3 +394,14 @@ struct device { */ int (*send_bluetooth_call_volume)(hid_device* hid_device, uint8_t num); }; + +/** + * @brief Node structure for a linked list of devices. + * + * This structure represents a node in a linked list where each node contains a pointer to a device + * and a pointer to the next node in the list. + */ +typedef struct DeviceListNode { + struct device* element; + struct DeviceListNode* next; +} DeviceListNode; diff --git a/src/main.c b/src/main.c index ea2b9af..52a3c4f 100644 --- a/src/main.c +++ b/src/main.c @@ -40,11 +40,16 @@ int test_profile = 0; int hsc_device_timeout = 5000; -typedef struct DeviceListNode { - struct device* element; - struct DeviceListNode* next; -} DeviceListNode; - +/** + * @brief Finds and initializes a list of devices. + * + * This function allocates a list of devices. + * If the test_device flag is set, it attempts to add a test device to the list. + * + * @param device_list A pointer to the list of devices to be populated. + * @param test_device A flag indicating whether to add a test device to the list. + * @return The number of devices found and added to the list. + */ static int find_devices(DeviceList** device_list, int test_device) { DeviceListNode* devices_found = malloc(sizeof(DeviceListNode));