From: Mika Laitio Date: Wed, 15 Aug 2012 09:28:46 +0000 (+0300) Subject: memory leak fixes X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=a57676dd868649b99e81075263b565cc0e411131;p=libplpdevicebus.git memory leak fixes Signed-off-by: Mika Laitio --- diff --git a/src_client/DeviceManagerClient.cc b/src_client/DeviceManagerClient.cc index 3c47f4e..9551282 100644 --- a/src_client/DeviceManagerClient.cc +++ b/src_client/DeviceManagerClient.cc @@ -45,8 +45,6 @@ DeviceManagerClient::~DeviceManagerClient() { const std::list *DeviceManagerClient::get_device_list(BusClient *client_param, int *err_flg) { - //send_request__get_device_list(client_param); - BusMessage *msg_req; BusMessage *msg_rsp; @@ -77,13 +75,12 @@ void DeviceManagerClient::parse_device_data_msg(BusMessage *msg_param, if (data_str.empty() == false) { data = Data::parse_string(data_str); } - if (data == NULL) { - data = new Data(0); + if (data != NULL) { + result->add(data); + log_debug("%s\n", description.c_str()); + data->printout(); + delete(data); } - result->add(data); - log_debug("%s\n", description.c_str()); - data->printout(); - delete(data); } } @@ -141,11 +138,13 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param Data *data; list *ret_val; + ret_val = new list; count = msg_param->get_long_parameter(RSP__DEVICE_LIST__DEVICE_COUNT, err_flg); log_debug("device count: %ld\n", count); - ret_val = new list; if (*err_flg == PLP_OK) { for (ii = 0; ii < count; ii++) { + data = NULL; + key.str(""); key << RSP__DEVICE_LIST__ID << ii; id = msg_param->get_string_parameter(key.str(), err_flg); @@ -185,14 +184,11 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param if (*err_flg == PLP_OK) { data = Data::parse_string(datastr); if (data == NULL) { - log_error("Failed to parse data items for the device: %s\n", id.c_str()); - *err_flg = PLP_ERR; - break; + log_error("No data available for the device: %s\n", id.c_str()); } } else { log_error("No data available for the device: %s\n", id.c_str()); - data = new Data(0); } dev = new DeviceData(id, type, name, state, data); ret_val->push_back(dev);