X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FStandard%2FStandard_Type.cxx;h=db12772aecc80956375851c7fe395ceb01e730ce;hb=a0218ba1c5e079c1b2dde57114ea120dc999dd93;hpb=325e442bce516824561805fa9f1c73f20f76f13b diff --git a/src/Standard/Standard_Type.cxx b/src/Standard/Standard_Type.cxx index 06f6ac3ce4..db12772aec 100644 --- a/src/Standard/Standard_Type.cxx +++ b/src/Standard/Standard_Type.cxx @@ -23,6 +23,27 @@ IMPLEMENT_STANDARD_RTTIEXT(Standard_Type,Standard_Transient) //============================================================================ +namespace { +static Standard_CString copy_string (const char* theString) +{ + size_t aLength = strlen (theString); + char* aResult = static_cast (Standard::Allocate (aLength + 1)); + strncpy (aResult, theString, aLength + 1); //including null-character + return aResult; +} +} + +Standard_Type::Standard_Type (const char* theSystemName, + const char* theName, + Standard_Size theSize, + const Handle(Standard_Type)& theParent) : + mySystemName (copy_string (theSystemName)), + myName(theName), mySize(theSize), myParent(theParent) +{ +} + +//============================================================================ + Standard_Boolean Standard_Type::SubType (const Handle(Standard_Type)& theOther) const { return ! theOther.IsNull() && (theOther == this || (! myParent.IsNull() && myParent->SubType (theOther))); @@ -91,7 +112,7 @@ Standard_Type* Standard_Type::Register (const char* theSystemName, const char* t aType = new Standard_Type (theSystemName, theName, theSize, theParent); // then add it to registry and return (the reference to the handle stored in the registry) - aRegistry.Bind (theSystemName, aType); + aRegistry.Bind (aType->mySystemName, aType); // cout << "Registering " << theSystemName << ": " << aRegistry.Extent() << endl; @@ -105,4 +126,5 @@ Standard_Type::~Standard_Type () Standard_ASSERT(aRegistry.UnBind (mySystemName), "Standard_Type::~Standard_Type() cannot find itself in registry",); // cout << "Unregistering " << mySystemName << ": " << aRegistry.Extent() << endl; + Standard::Free (mySystemName); }