]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: remove memory leaks
authorcaremoli <caremoli>
Mon, 18 Feb 2008 09:44:17 +0000 (09:44 +0000)
committercaremoli <caremoli>
Mon, 18 Feb 2008 09:44:17 +0000 (09:44 +0000)
src/DSC/DSC_User/Basic/data_short_port_provides.hxx
src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx
src/DSC/DSC_User/Datastream/Calcium/CalciumProvidesPort.hxx
src/DSC/DSC_User/Datastream/Calcium/calcium_integer_port_uses.hxx
src/DSC/DSC_User/Datastream/GenericPort.hxx
src/DSC/DSC_User/Datastream/GenericUsesPort.hxx
src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx
src/DSC/DSC_User/Superv_Component_i.cxx
src/DSC/DSC_User/Superv_Component_i.hxx

index df33f65510784f58195a7bc96e56e825dacf9812..51ae3afd92d2f5eb3f576a11b7068cce94548d84 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef _DATA_SHORT_PORT_PROVIDES_HXX_
 #define _DATA_SHORT_PORT_PROVIDES_HXX_
 
+#include <SALOMEconfig.h>
+
 #include <iostream>
 #include "SALOME_Ports.hh"
 #include "provides_port.hxx"
index c17ddb80a321f590114eb6925658bbc0579755ed..39a8cac490f3ac57edf3170a4747b52891de6379 100644 (file)
@@ -43,6 +43,18 @@ extern "C"
       {
         dynamic_cast<calcium_integer_port_provides *>(port)->setDependencyType(depend);
       }
+    else if(std::string(type)=="CALCIUM_string")
+      {
+        dynamic_cast<calcium_string_port_provides *>(port)->setDependencyType(depend);
+      }
+    else if(std::string(type)=="CALCIUM_logical")
+      {
+        dynamic_cast<calcium_logical_port_provides *>(port)->setDependencyType(depend);
+      }
+    else if(std::string(type)=="CALCIUM_complex")
+      {
+        dynamic_cast<calcium_complex_port_provides *>(port)->setDependencyType(depend);
+      }
     else
       {
         std::cerr << "unknown type:" << std::endl;
index 075132663b67ec791642ffef4032afd3865191f1..e22288f6a55548c14fdd5f09068ef22f31d68ce2 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _CALCIUM_PORT_PROVIDES_HXX_
 #define _CALCIUM_PORT_PROVIDES_HXX_
 
+#include <SALOMEconfig.h>
+
 #include "Calcium_Ports.hh"
 #include "CalciumGenericProvidesPort.hxx"
 #include "CalciumCouplingPolicy.hxx"
index 6733cdbdfa625e32ca951b725abbc552b9d135da..3216a20f402317ddf46ecc94104275d863a33554 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _CALCIUM_INTEGER_PORT_USES_HXX_
 #define _CALCIUM_INTEGER_PORT_USES_HXX_
 
+#include <SALOMEconfig.h>
+
 #include "Calcium_Ports.hh"
 #include "CalciumGenericUsesPort.hxx"
 
index fbb324341b432ad8e2983d6d6e6b6debcaa68aa4..dd6005780010e26042d65d9b89b018d79d6c1e67 100644 (file)
@@ -103,10 +103,12 @@ GenericPort<DataManipulator, COUPLING_POLICY >::GenericPort() :
 template < typename DataManipulator, typename COUPLING_POLICY>
 GenericPort<DataManipulator, COUPLING_POLICY>::~GenericPort() {
   typename DataTable::iterator it;
-  //   for (it=storedDatas.begin(); it!=storedDatas.end(); ++it) {
-  //     std::cout << "~GenericPort() : destruction de la donnnée associée au DataId :"<<  (*it).first << std::endl;
-  //     DataManipulator::delete_data( (*it).second );
-  //   }
+  for (it=storedDatas.begin(); it!=storedDatas.end(); ++it) {
+#ifdef _DEBUG_
+    std::cerr << "~GenericPort() : destruction de la donnnée associée au DataId :"<<  (*it).first << std::endl;
+#endif
+    DataManipulator::delete_data( (*it).second );
+  }
 }
 
 template < typename DataManipulator, typename COUPLING_POLICY> void 
index 2c01e49af7461502736d9c92483696e4a2d164be..effed2b0725255ec4de0eb3be6be6fd7986bdaf3 100644 (file)
@@ -72,7 +72,10 @@ GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort  >::Gen
 }
 
 template <typename DataManipulator,typename CorbaPortType, char * repositoryName, typename UsesPort > 
-GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort  >::~GenericUsesPort() {}
+GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort  >::~GenericUsesPort() 
+{
+  delete _my_ports;
+}
 
 template <typename DataManipulator,typename CorbaPortType, char * repositoryName, typename UsesPort > 
 const char *
@@ -87,7 +90,7 @@ void
 GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort  >::put( CorbaInDataType data, 
                                                                                  TimeType time, 
                                                                                  TagType tag) {
-  typedef typename CorbaPortType::_ptr_type CorbaPortTypePtr;
+  typedef typename CorbaPortType::_var_type CorbaPortTypeVar;
   if (!_my_ports)
     throw DSC_Exception(LOC("There is no connected provides port to communicate with."));
 
@@ -101,7 +104,7 @@ GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort  >::put
   // OLD :  DataType copyOfData; // = data; PB1
   for(int i = 0; i < _my_ports->length(); i++) {
 
-    CorbaPortTypePtr port = CorbaPortType::_narrow((*_my_ports)[i]);
+    CorbaPortTypeVar port = CorbaPortType::_narrow((*_my_ports)[i]);
     //if (i) { PB1
     //OLD :   copyOfData = DataManipulator::clone(data);
 #ifdef _DEBUG_
@@ -137,7 +140,7 @@ GenericUsesPort< DataManipulator, CorbaPortType, repositoryName, UsesPort
 #ifdef _DEBUG_
   std::cerr << "GenericUsesPort::uses_port_changed" << std::endl;
 #endif
-  _my_ports = new Engines::DSC::uses_port(*new_uses_port);
+  _my_ports = new_uses_port;
 }
 
 #endif
index 30cdf27d73f6bb6fa174fcb570890e995673b17b..c5f57fff49ed5275ac27837bb08b92e90f174a94 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _PALM_COUPLING_POLICIES_HXX_
 #define _PALM_COUPLING_POLICIES_HXX_
 
+#include <SALOMEconfig.h>
+
 #include <CORBA.h>
 #include <vector>
 #include "DataIdFilter.hxx"
index 72cbef19bc6ac13c1269a357745a7d7358c0fc2e..3f2a3e972a17535254fcd1348a66cdc537269938 100644 (file)
@@ -60,6 +60,11 @@ Superv_Component_i::~Superv_Component_i()
   {
     delete begin->second;
   }
+
+  my_superv_ports_it = my_superv_ports.begin();
+  for(;my_superv_ports_it != my_superv_ports.end();my_superv_ports_it++) 
+    delete my_superv_ports_it->second;
+
 }
 
 void 
@@ -179,9 +184,11 @@ Superv_Component_i::add_port(provides_port * port,
 
   try {
 
-    Engines_DSC_interface::add_provides_port(port->get_port_ref(), 
+    Ports::PortProperties_var portproperties=port->get_port_properties();
+    Ports::Port_var portref=port->get_port_ref();
+    Engines_DSC_interface::add_provides_port(portref, 
                                             provides_port_name,
-                                            port->get_port_properties());
+                                            portproperties);
 
     superv_port_t * new_superv_port = new superv_port_t();
     new_superv_port->p_ref = port;
@@ -209,9 +216,10 @@ Superv_Component_i::add_port(uses_port * port,
   assert(uses_port_name);
 
   try {
+    Ports::PortProperties_var portproperties=port->get_port_properties();
     Engines_DSC_interface::add_uses_port(port->get_repository_id(), 
                                         uses_port_name,
-                                        port->get_port_properties());
+                                        portproperties);
     superv_port_t * new_superv_port = new superv_port_t();
     new_superv_port->u_ref = port;
     my_superv_ports[uses_port_name] = new_superv_port;
@@ -236,7 +244,7 @@ Superv_Component_i::get_port(provides_port *& port,
   assert(provides_port_name);
 
   try {
-    Engines_DSC_interface::get_provides_port(provides_port_name, false);
+    Ports::Port_var portref=Engines_DSC_interface::get_provides_port(provides_port_name, false);
     port = my_superv_ports[provides_port_name]->p_ref;
   } catch (const Engines::DSC::PortNotDefined&) {
     throw PortNotDefined( LOC(OSS()<< "Le port provides  "
@@ -255,7 +263,8 @@ Superv_Component_i::get_port(uses_port *& port,
   assert(uses_port_name);
 
   try {
-    Engines_DSC_i::get_uses_port(uses_port_name);
+    Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(uses_port_name);
+    delete portseq;
     port = my_superv_ports[uses_port_name]->u_ref;
   } catch (const Engines::DSC::PortNotDefined&) {    
     throw PortNotDefined( LOC(OSS()<< "Le port uses  "
@@ -286,8 +295,10 @@ Superv_Component_i::uses_port_changed(const char* uses_port_name,
 {
   my_superv_ports_it = my_superv_ports.find(uses_port_name);
   if (my_superv_ports_it !=  my_superv_ports.end())
-    my_superv_ports[uses_port_name]->u_ref->uses_port_changed(new_uses_port,
+    my_superv_ports[uses_port_name]->u_ref->uses_port_changed(new Engines::DSC::uses_port(*new_uses_port),
                                                              message);
+  //delete the copy made by the caller
+  delete new_uses_port;
 }
 
 
index cf61ce458ca134e64526e93cf250ab736c2d8b76..174380f050558a247ac3e5eea60a0586e16f4a61 100644 (file)
@@ -263,6 +263,11 @@ private:
   // A Superv_Component port.
   struct superv_port_t {
     superv_port_t():u_ref(NULL),p_ref(NULL){};
+    ~superv_port_t()
+    {
+      if(u_ref)delete u_ref;
+      if(p_ref)delete p_ref;
+    };
     // For uses ports.
     uses_port * u_ref;
     // For provides ports.
@@ -346,11 +351,12 @@ Superv_Component_i::get_port( const char * port_name)
   try {
     if ( superv_port->p_ref != NULL ) {
       port = superv_port->p_ref;
-      Engines_DSC_interface::get_provides_port(port_name, false); 
+      Ports::Port_var portref=Engines_DSC_interface::get_provides_port(port_name, false); 
     } 
     else if ( superv_port->u_ref != NULL ) {
       port = superv_port->u_ref;
-      Engines_DSC_i::get_uses_port(port_name);
+      Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(port_name);
+      delete portseq;
     } else {
       throw UnexpectedState( LOC(OSS()<< "Internal Error superv_port struct is inconsistent "));