From: Mika Laitio Date: Wed, 25 Jul 2012 13:20:13 +0000 (+0300) Subject: memory leak fixes X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=3fa4e34aef7999eb6f6e8015ad4e2ae640f8f183;p=libplpdevicebus.git memory leak fixes Signed-off-by: Mika Laitio --- diff --git a/src_server/DeviceManagerServer.cc b/src_server/DeviceManagerServer.cc index 8257561..22a8c6c 100644 --- a/src_server/DeviceManagerServer.cc +++ b/src_server/DeviceManagerServer.cc @@ -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(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++;