}
else
{
- CORBA::Object_ptr obj = NS->Resolve(serverName.c_str());
+ CORBA::Object_var obj = NS->Resolve(serverName.c_str());
if (! CORBA::is_nil(obj))
{
found =1;
ASSERT(!CORBA::is_nil(_current_context));
- CORBA::Object_ptr obj = CORBA::Object::_nil();
+ CORBA::Object_var obj = CORBA::Object::_nil();
try
{
throw ServiceUnreachable();
}
- return obj;
+ return obj._retn();
}
// ============================================================================
}
// SCRUTE(name);
- CORBA::Object_ptr obj = CORBA::Object::_nil();
+ CORBA::Object_var obj = CORBA::Object::_nil();
bool isOk = false;
if (basePath.empty())
}
}
- return obj;
+ return obj._retn();
}
// ============================================================================
if (binding->binding_type == CosNaming::nobject)
{
- dirList.push_back(CORBA::string_dup(bindingName[0].id));
+ // remove memory leak
+ // dirList.push_back(CORBA::string_dup(bindingName[0].id));
+ dirList.push_back(string(bindingName[0].id));
}
}
SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var Str = CORBA::string_dup(value);
- Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_impl)->SetValue(TCollection_ExtendedString(Str));
+ TCollection_ExtendedString anExtStr((char *)Str.in());
+ Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_impl)->SetValue(anExtStr);
}
std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
{
- return _orb->object_to_string(theObject);
+ CORBA::String_var objStr = _orb->object_to_string(theObject);
+ return string( objStr.in() );
}
CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
aSCO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSComponent((char*)aComponent->GetID());
CORBA::String_var iorstr = _orb->object_to_string(IOR);
- _impl->DefineComponentInstance(aSCO, (char*)iorstr);
+ _impl->DefineComponentInstance(aSCO, (char*)iorstr.in());
}
//============================================================================
_name_service->Register(Study, study_name);
// Assign the value of the IOR in the study->root
- const char* IORStudy = _orb->object_to_string(Study);
+ CORBA::String_var IORStudy = _orb->object_to_string(Study);
- aStudyImpl->SetTransientReference((char*)IORStudy);
+ aStudyImpl->SetTransientReference((char*)IORStudy.in());
_mapOfPOA[Study->StudyId()] = _poa;
// Assign the value of the IOR in the study->root
CORBA::String_var IORStudy = _orb->object_to_string(Study);
- aStudyImpl->SetTransientReference((char*)IORStudy);
+ aStudyImpl->SetTransientReference((char*)IORStudy.in());
// Register study in the naming service
// Path to acces the study
aSO = _impl->FindObjectID(aSObj->GetID());
}
else {
- aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
+ CORBA::String_var objStr = _orb->object_to_string(theObject);
+ TCollection_AsciiString anAscii((char *)objStr.in());
+ aSO = _impl->FindObjectIOR(anAscii);
}
if(aSO.IsNull()) return CORBA::string_dup(aPath.ToCString());
const char* get_uname( void )
{
- char* hostName = new char[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD nSize = MAX_COMPUTERNAME_LENGTH;
- // initialisaton
- hostName[0]='\0';
- ASSERT(GetComputerName(hostName, &nSize));
- return hostName;
+ static std::string hostName(MAX_COMPUTERNAME_LENGTH + 1, 0);
+ static DWORD nSize = hostName.length() + 1;
+ static int res = GetComputerName(&hostName[0], &nSize);
+ ASSERT( res );
+ return hostName.c_str();
}
const char* get_adip( void )
const char* const get_pwname( void )
{
- DWORD dwSize = 256 + 1;
- char* retVal = new char[256];
- // initialisaton
- retVal[0]='\0';
- ASSERT(GetUserName` ( retVal, &dwSize ));
- return retVal;
+ static std::string retVal(256, 0);
+ static DWORD dwSize = retVal.length() + 1;
+ static int res = GetUserName( &retVal[0], &dwSize );
+ ASSERT( res );
+ return retVal.c_str();
}
PSID getuid() {
//delete [] (char*)_dir ;
//(char*&)_dir = NULL ;
free((char*)_dir);
-
+#ifndef WIN32
+ // free the memory only on Unix
+ // becasue at Windows it is the same static variable
+ // (function get_adip() returns the same char* as get_uname() )
delete [] (char*)_adip ;
+#endif
(char*&)_adip = NULL ;
+
}
/*------------*/