From: Mika Laitio Date: Wed, 25 Jul 2012 13:19:09 +0000 (+0300) Subject: memory leak fixes X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=db8faefedaf3d3e94865002485d8b5fa491ce4c5;p=libplpbus.git memory leak fixes Signed-off-by: Mika Laitio --- diff --git a/src/idl/RequestResponseBus.idl b/src/idl/RequestResponseBus.idl index 0bbd1f0..b3617fa 100644 --- a/src/idl/RequestResponseBus.idl +++ b/src/idl/RequestResponseBus.idl @@ -5,11 +5,10 @@ module plpbus_orb { struct DataItem { string name; any value; - string str_value; + string str_value; }; typedef sequence DataItemSequence; - interface OrbClient { // send event to orb client diff --git a/src/plpbus/BusMessage.hh b/src/plpbus/BusMessage.hh index 05fba36..3a2cd09 100644 --- a/src/plpbus/BusMessage.hh +++ b/src/plpbus/BusMessage.hh @@ -10,11 +10,15 @@ #include +#include "RequestResponseBus.hh" + +using namespace plpbus_orb; + namespace plpbus { class BusMessage { public: - void *_dataItemSeq; + DataItemSequence *_dataItemSeq; BusMessage(long type_param); BusMessage(long type_param, const char *arg_name_param, const char *arg_string_value_param); diff --git a/src/plpbus/OrbServerImpl.cc b/src/plpbus/OrbServerImpl.cc index 0d98bad..1207f91 100644 --- a/src/plpbus/OrbServerImpl.cc +++ b/src/plpbus/OrbServerImpl.cc @@ -105,25 +105,25 @@ void OrbServerImpl::send_dataitem_message_and_request_response(OrbClient_ptr res } } +void copy( const DataItemSequence& orig_seq ) +{ + DataItemSequence new_seq; + + new_seq = orig_seq; +} + CORBA::Long OrbServerImpl::send_dataitem_message_and_wait_response(const DataItemSequence& req_seq_param, DataItemSequence_out rsp_seq_param) { - BusMessage *msg_req; - BusMessage *msg_rsp; - DataItemSequence *seq; - int err_flg; + BusMessage *msg_req; + BusMessage *msg_rsp; + int err_flg; - seq = NULL; - msg_rsp = NULL; msg_req = new BusMessageInternal(req_seq_param); msg_rsp = new BusMessage(msg_req->get_type(&err_flg)); _listener->request_received(msg_req, msg_rsp); - if (msg_rsp != NULL) { - seq = (DataItemSequence *)msg_rsp->_dataItemSeq; - } - else { - seq = new DataItemSequence(); - } - rsp_seq_param._data = seq; + rsp_seq_param._data = new DataItemSequence(*(msg_rsp->_dataItemSeq)); + delete(msg_req); + delete(msg_rsp); return 0; }