From 71ba668c44e244eb69390440c3a64921ac466f77 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 13 Oct 2019 14:11:54 +0100 Subject: [PATCH] Free device info list. --- dicmote.h | 1 + list_devices.c | 17 ++++++++++++++++- main.c | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dicmote.h b/dicmote.h index 20c8ad9..a40cd6e 100644 --- a/dicmote.h +++ b/dicmote.h @@ -82,5 +82,6 @@ typedef struct DeviceInfoList #pragma pack(pop) DeviceInfoList* ListDevices(); +void FreeDeviceInfoList(DeviceInfoList* start); #endif diff --git a/list_devices.c b/list_devices.c index 33ec03f..6bd5e32 100644 --- a/list_devices.c +++ b/list_devices.c @@ -21,11 +21,26 @@ #include "linux/linux.h" #endif +#include +#include + DeviceInfoList* ListDevices() { #if defined(__linux__) && !defined(__ANDROID__) return linux_list_devices(); #else - return 0; + return NULL; #endif +} + +void FreeDeviceInfoList(DeviceInfoList* start) +{ + DeviceInfoList* current; + + while(start) + { + current = start; + start = current->next; + free(current); + } } \ No newline at end of file diff --git a/main.c b/main.c index b6c56a7..6c990e3 100644 --- a/main.c +++ b/main.c @@ -317,6 +317,8 @@ int main() continue; } + FreeDeviceInfoList(deviceInfoList); + printf("List devices not yet implemented, skipping...\n"); continue; case DICMOTE_PACKET_TYPE_RESPONSE_LIST_DEVICES: