From ab6480ebcafbd17ae890153d3f3757af61de5538 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 6 Oct 2023 00:17:15 +0200 Subject: [PATCH] Fixed more meory leaks. --- apps/aqhome-mqttlog/fini.c | 5 +++++ apps/aqhome-mqttlog/main.c | 22 ++++++---------------- apps/aqhome-mqttlog/types/device.t2d | 1 + apps/aqhome-mqttlog/types/topic.t2d | 1 + apps/aqhome-mqttlog/types/value.t2d | 1 + 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/aqhome-mqttlog/fini.c b/apps/aqhome-mqttlog/fini.c index 2209428..610f8f3 100644 --- a/apps/aqhome-mqttlog/fini.c +++ b/apps/aqhome-mqttlog/fini.c @@ -55,6 +55,11 @@ void AqHomeMqtt_Fini(AQHOME_MQTT *aqh) aqh->brokerEndpoint=NULL; aqh->mqttEndpoint=NULL; + AQHMQTT_Device_List_free(aqh->availableDeviceList); + aqh->availableDeviceList=NULL; + AQHMQTT_Device_List_free(aqh->registeredDeviceList); + aqh->registeredDeviceList=NULL; + if (aqh->pidFile) remove(aqh->pidFile); } diff --git a/apps/aqhome-mqttlog/main.c b/apps/aqhome-mqttlog/main.c index 9398fca..7dcb9ea 100644 --- a/apps/aqhome-mqttlog/main.c +++ b/apps/aqhome-mqttlog/main.c @@ -58,7 +58,7 @@ * ------------------------------------------------------------------------------------------------ */ -static int _serve(AQHOME_MQTT *aqh); +static void _serve(AQHOME_MQTT *aqh); #ifdef HAVE_SIGNAL_H static int _setSignalHandlers(void); @@ -124,11 +124,7 @@ int main(int argc, char **argv) GWEN_Gui_SetCharSet(gui, s); GWEN_Gui_SetGui(gui); - rv=_serve(aqh); - if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return 2; - } + _serve(aqh); AqHomeMqtt_Fini(aqh); AqHomeMqtt_free(aqh); @@ -141,9 +137,8 @@ int main(int argc, char **argv) -int _serve(AQHOME_MQTT *aqh) +void _serve(AQHOME_MQTT *aqh) { - GWEN_MSG_ENDPOINT *epTcp; int rv; int timeout; time_t startTime; @@ -156,16 +151,14 @@ int _serve(AQHOME_MQTT *aqh) rv=_setSignalHandlers(); if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return rv; + DBG_ERROR(NULL, "Error setting signal handlers (%d)", rv); + return; } timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0); lastPingSendTime=time(NULL); - epTcp=AqHomeMqtt_GetMqttEndpoint(aqh); - while(!stopService) { DBG_DEBUG(NULL, "Next loop"); AqHomeMqttLog_Loop(aqh, 2000); @@ -175,7 +168,7 @@ int _serve(AQHOME_MQTT *aqh) now=time(NULL); if ((now-startTime)>timeout) { - DBG_INFO(NULL, "Timeout, stopping service"); + DBG_ERROR(NULL, "Timeout, stopping service"); break; } } @@ -192,9 +185,6 @@ int _serve(AQHOME_MQTT *aqh) } } } - - GWEN_MsgEndpoint_free(epTcp); - return 0; } diff --git a/apps/aqhome-mqttlog/types/device.t2d b/apps/aqhome-mqttlog/types/device.t2d index 0d17bdf..205c1a0 100644 --- a/apps/aqhome-mqttlog/types/device.t2d +++ b/apps/aqhome-mqttlog/types/device.t2d @@ -63,6 +63,7 @@ public own noconst none + none diff --git a/apps/aqhome-mqttlog/types/topic.t2d b/apps/aqhome-mqttlog/types/topic.t2d index 871d571..7a8351c 100644 --- a/apps/aqhome-mqttlog/types/topic.t2d +++ b/apps/aqhome-mqttlog/types/topic.t2d @@ -96,6 +96,7 @@ public own none + none diff --git a/apps/aqhome-mqttlog/types/value.t2d b/apps/aqhome-mqttlog/types/value.t2d index 64154f6..9bb2883 100644 --- a/apps/aqhome-mqttlog/types/value.t2d +++ b/apps/aqhome-mqttlog/types/value.t2d @@ -80,6 +80,7 @@ public own none + none