From: rahuel Date: Wed, 9 Mar 2005 07:48:58 +0000 (+0000) Subject: Memory Leaks X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea7f29f75031ca13b9454f5e9ac73730f1f584eb;p=modules%2Fsuperv.git Memory Leaks Remove of "old clutter methods" --- diff --git a/src/GraphBase/DataFlowBase_DataPort.cxx b/src/GraphBase/DataFlowBase_DataPort.cxx index 1f6d837..9aac0d3 100644 --- a/src/GraphBase/DataFlowBase_DataPort.cxx +++ b/src/GraphBase/DataFlowBase_DataPort.cxx @@ -33,7 +33,7 @@ using namespace std; GraphBase::DataPort::DataPort() : Port() { pthread_mutex_init( &_MutexWait , NULL ) ; - _State = SUPERV::UndefinedState ; + _PortState = SUPERV::UndefinedState ; _Done = false ; InitialValues( CORBA::Any() ) ; } @@ -44,7 +44,7 @@ GraphBase::DataPort::DataPort( const char *const * NodeName , const SALOME_ModuleCatalog::DataStreamDependency aDependency ) : Port( NodeName , aserviceParameter , aKind , aDependency ) { pthread_mutex_init( &_MutexWait , NULL ) ; - _State = SUPERV::UndefinedState ; + _PortState = SUPERV::UndefinedState ; _Done = false ; InitialValues( CORBA::Any() ) ; } @@ -54,7 +54,8 @@ GraphBase::DataPort::~DataPort() { void GraphBase::DataPort::InitialValues(CORBA::Any aValue ) { _theValue = new CORBA::Any( aValue ) ; - string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ; +//JR 24.02.2005 Memory Leak string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ; + string _Type = string( GetServicesParameter().Parametertype ) ; const char * Type = _Type.c_str(); CORBA::Any InitialValue ; cdebug << "InitialValues " << NodeName() << " " << PortName() << " " << PortType() @@ -125,8 +126,9 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { delete _theValue ; - string _Type = CORBA::string_dup( GetServicesParameter().Parametertype ) ; - const char * Type = _Type.c_str() ; +//JR 21.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( GetServicesParameter().Parametertype ) ; +// const char * Type = _Type.c_str() ; + const char * Type = GetServicesParameter().Parametertype ; _Value = &_theValue ; cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType() << " : " << aDataValue << " kind " << aDataValue->type()->kind() << " " ; @@ -172,6 +174,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { } _theValue = theValue ; *_Value = theValue ; +//JR 21.02.2005 Debug Memory leak : + delete aDataValue ; } break; } @@ -211,6 +215,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { } _theValue = theValue ; *_Value = theValue ; +//JR 21.02.2005 Debug Memory leak : + delete aDataValue ; } break; } @@ -250,6 +256,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { } _theValue = theValue ; *_Value = theValue ; +//JR 21.02.2005 Debug Memory leak : + delete aDataValue ; } break; } @@ -288,6 +296,8 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { } _theValue = theValue ; *_Value = theValue ; +//JR 21.02.2005 Debug Memory leak : + delete aDataValue ; } break; } @@ -307,41 +317,6 @@ void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { } -void GraphBase::DataPort::Value( const CORBA::Any ** aDataSharedValue ) { - delete _theValue ; - _theValue = *aDataSharedValue ; - _Value = aDataSharedValue ; -// Done( true ) ; - -#if 0 - MESSAGE( NodePortName() << " : " << hex << _Value << " " ); - switch (_theValue->type()->kind()) { - case CORBA::tk_string: - char * t; - *_theValue >>= t; - MESSAGE( "Value( " << t << ") (string)"); - break; - case CORBA::tk_double: - double d; - *_theValue >>= d; - MESSAGE( "Value( " << d << ") (double)"); - break; - case CORBA::tk_long: - long l; - *_theValue >>= l; - MESSAGE( "Value( " << l << ") (long)"); - break; - case CORBA::tk_objref: - MESSAGE( "Value( " << ") (object reference)"); - break; - default: - MESSAGE( "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR"); - break; - } - MESSAGE(); -#endif -} - CORBA::Any const * GraphBase::DataPort::Value() const { pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ; // cdebug << pthread_self() << " Value() --> pthread_mutex_lock " << aMutexWait << endl ; @@ -361,8 +336,9 @@ CORBA::Any const * GraphBase::DataPort::Value() const { else { // cdebug << " Null" << endl ; } - if ( Done() ) { - theValue = new CORBA::Any( *Value ) ; + if ( PortDone() ) { +//JR 21.02.2005 Debug Memory leak : theValue = new CORBA::Any( *Value ) ; + theValue = (CORBA::Any * ) Value ; switch ( theValue->type()->kind() ) { case CORBA::tk_string: { char * t; @@ -405,7 +381,8 @@ CORBA::Any const * GraphBase::DataPort::Value() const { } else { // cdebug << "GraphBase::DataPort::InitialValue() " << endl ; - theValue = new CORBA::Any( *Value ) ; +//JR 21.02.2005 Debug Memory leak : theValue = new CORBA::Any( *Value ) ; + theValue = (CORBA::Any * ) Value ; } if ( pthread_mutex_unlock( aMutexWait ) ) { perror( "unlock DataValue" ) ; @@ -418,7 +395,6 @@ CORBA::Any const * GraphBase::DataPort::Value() const { bool GraphBase::DataPort::BoolValue() const { bool RetVal = false ; - long val ; pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ; // cdebug << pthread_self() << " BoolValue() --> pthread_mutex_lock " << aMutexWait << endl ; if ( pthread_mutex_lock( aMutexWait ) ) { @@ -428,6 +404,14 @@ bool GraphBase::DataPort::BoolValue() const { // cdebug << pthread_self() << " BoolValue() --> pthread_mutex_locked " << aMutexWait // << endl ; if ( (*_Value)->type()->kind() == CORBA::tk_long ) { + long val ; + **_Value >>= val ; + if ( val ) { + RetVal = true ; + } + } + else if ( (*_Value)->type()->kind() == CORBA::tk_boolean ) { + bool val ; **_Value >>= val ; if ( val ) { RetVal = true ; @@ -437,15 +421,10 @@ bool GraphBase::DataPort::BoolValue() const { perror( "unlock DataValue" ) ; exit( 0 ) ; } -// cdebug << pthread_self() << " BoolValue() --> pthread_mutex_unlocked " << aMutexWait -// << endl ; + cdebug << pthread_self() << " " << NodeName() << "( " << PortName() << " ) BoolValue " << RetVal << endl ; return RetVal ; } -const CORBA::Any ** GraphBase::DataPort::ValuePtr() const { - return _Value ; -} - void GraphBase::DataPort::StringValue(ostream & f ) const { pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ; // cdebug << pthread_self() << " StringValue() --> pthread_mutex_lock " << aMutexWait @@ -456,7 +435,7 @@ void GraphBase::DataPort::StringValue(ostream & f ) const { } // cdebug << pthread_self() << " StringValue() --> pthread_mutex_locked " << aMutexWait // << endl ; - if ( Done() ) { + if ( PortDone() ) { // cdebug << "StringValue " << NodeName() << " " << PortName() << " " << PortType() // << " _Value " << _Value << " *_Value " // << *_Value << " " << endl ; @@ -493,7 +472,7 @@ void GraphBase::DataPort::StringValue(ostream & f ) const { } } else { - f << " Default (undefined) NOT DONE" ; + f << " Default (undefined) DATAPORT NOT DONE" ; } if ( pthread_mutex_unlock( aMutexWait ) ) { perror( "unlock DataValue" ) ; diff --git a/src/GraphBase/DataFlowBase_DataPort.hxx b/src/GraphBase/DataFlowBase_DataPort.hxx index 0dd2c29..d15f029 100644 --- a/src/GraphBase/DataFlowBase_DataPort.hxx +++ b/src/GraphBase/DataFlowBase_DataPort.hxx @@ -40,10 +40,14 @@ namespace GraphBase { CORBA::Any const * _InitialValue ; CORBA::Any const * _theValue ; CORBA::Any const * * _Value ; - SUPERV::GraphState _State ; +//JR 08.03.2005 : the fields (and corresponding methods) _PortState and _Done are redundant +// probably. That should be clarified when I shall have time enough + SUPERV::GraphState _PortState ; bool _Done ; pthread_mutex_t _MutexWait ; + void Value( const CORBA::Any * aValue ) ; + public : DataPort() ; @@ -55,21 +59,21 @@ namespace GraphBase { void InitialValues(CORBA::Any aValue ) ; void Value (const CORBA::Any & aValue ) ; - void Value( const CORBA::Any * aValue ) ; - void Value( const CORBA::Any ** aValue ) ; +// void Value( const CORBA::Any * aValue ) ; +// void Value( const CORBA::Any ** aValue ) ; CORBA::Any const * Value() const ; bool BoolValue() const ; - const CORBA::Any ** ValuePtr() const ; +// const CORBA::Any ** ValuePtr() const ; - void State( SUPERV::GraphState aState ) { - _State = aState ; } ; - SUPERV::GraphState State() { return _State ; } ; + void PortState( SUPERV::GraphState aPortState ) { + _PortState = aPortState ; } ; + SUPERV::GraphState PortState() { return _PortState ; } ; - void Done( bool aDone ) { + void PortDone( bool aDone ) { // cdebug << "ChgDone(.) " << NodeName() << " " << PortName() << " " // << _Done << " -> " << aDone << endl ; _Done = aDone ; } ; - const bool Done() const { return ( _Done ) ; } ; + const bool PortDone() const { return ( _Done ) ; } ; void StringValue(ostream & f) const ;