]> pilppa.com Git - libplpdevicebus.git/commitdiff
memory leak fixes
authorMika Laitio <lamikr@pilppa.org>
Wed, 25 Jul 2012 13:20:13 +0000 (16:20 +0300)
committerMika Laitio <lamikr@pilppa.org>
Wed, 25 Jul 2012 13:20:13 +0000 (16:20 +0300)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src_server/DeviceManagerServer.cc

index 8257561467635217230f9bace4fb1436d4f2d44e..22a8c6c9e4a881bd13ad3045d87cdc40bf73a862 100644 (file)
@@ -26,6 +26,7 @@ static void *device_data_reader_thread(void *thread_args_pointer) {
        Device                          *device;
        SensorDevice                    *sensor;
        long                            read_int_sec;
+       plp::Data                       *data;
 
        read_int_sec    = DeviceConfig::get_read_interval_seconds();
        if (read_int_sec < 0)
@@ -36,7 +37,9 @@ static void *device_data_reader_thread(void *thread_args_pointer) {
                        device  = (Device *)*list_iter;
                        sensor = dynamic_cast<SensorDevice *>(device);
                        if (sensor != NULL) {
-                               sensor->get_data();
+                               data = sensor->get_data();
+                               if (data != NULL)
+                                       delete(data);
                        }
                }
                sleep(read_int_sec);
@@ -98,6 +101,7 @@ void DeviceManagerServer::get_device_list(const BusMessage *ret_val) {
                                if (data != NULL) {
                                        log_debug("returning data: %s\n", data->to_string().c_str());
                                        ((BusMessage *)ret_val)->add_string_parameter(key.str(), data->to_string());
+                                       delete(data);
                                }
                        }
                        indx++;