//============================================================================
+namespace {
+static Standard_CString copy_string (const char* theString)
+{
+ size_t aLength = strlen (theString);
+ char* aResult = static_cast<char*> (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)));
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;
Standard_ASSERT(aRegistry.UnBind (mySystemName), "Standard_Type::~Standard_Type() cannot find itself in registry",);
// cout << "Unregistering " << mySystemName << ": " << aRegistry.Extent() << endl;
+ Standard::Free (mySystemName);
}
//! Constructor is private
Standard_Type (const char* theSystemName, const char* theName,
- Standard_Size theSize, const Handle(Standard_Type)& theParent)
- : mySystemName(theSystemName), myName(theName), mySize(theSize), myParent(theParent)
- {
- }
+ Standard_Size theSize, const Handle(Standard_Type)& theParent);
private:
Standard_CString mySystemName; //!< System name of the class (typeinfo.name)