Destruction of TDF_LabelNode class corrected so as to use consistently defined new/delete operators
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#ifndef _NCollection_DefineAlloc_HeaderFile
# define _NCollection_DefineAlloc_HeaderFile
#ifndef _NCollection_DefineAlloc_HeaderFile
# define _NCollection_DefineAlloc_HeaderFile
+#include <NCollection_BaseAllocator.hxx>
+
// Macro to overload placement new and delete operators for NCollection allocators.
// For Borland C and old SUN compilers do not define placement delete
// as it is not supported.
// Macro to overload placement new and delete operators for NCollection allocators.
// For Borland C and old SUN compilers do not define placement delete
// as it is not supported.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// -------------
-
-// Version: 0.0
-//Version Date Purpose
-// 0.0 Feb 6 1997 Creation
-
-
-
#include <TDF_Data.ixx>
#include <TCollection_AsciiString.hxx>
#include <TDF_Data.ixx>
#include <TCollection_AsciiString.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NullObject.hxx>
+#include <NCollection_IncAllocator.hxx>
+
#undef DEB_DELTA_CREATION
#undef TDF_DATA_COMMIT_OPTIMIZED
#undef DEB_DELTA_CREATION
#undef TDF_DATA_COMMIT_OPTIMIZED
void TDF_Data::Destroy()
{
AbortUntilTransaction(1);
void TDF_Data::Destroy()
{
AbortUntilTransaction(1);
+ myRoot->Destroy (myLabelNodeAllocator);
+ myRoot = NULL;
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// --------------
-
-// Version: 0.0
-//Version Date Purpose
-// 0.0 Feb 6 1997 Creation
-
-
-
#include <TDF_Label.ixx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.ixx>
#include <TDF_Attribute.hxx>
}
else if (create) {
// Creates the label to be inserted always before currentLnp.
}
else if (create) {
// Creates the label to be inserted always before currentLnp.
- const Handle(NCollection_IncAllocator)& anIncAllocator =
- (const Handle(NCollection_IncAllocator)&)
- myLabelNode ->Data() -> LabelNodeAllocator();
- childLabelNode = new (anIncAllocator) TDF_LabelNode (aTag, myLabelNode);
+ const TDF_HAllocator& anAllocator = myLabelNode->Data()->LabelNodeAllocator();
+ childLabelNode = new (anAllocator) TDF_LabelNode (aTag, myLabelNode);
childLabelNode->myBrother = currentLnp; // May be NULL.
childLabelNode->Imported(IsImported());
//Inserts the label:
childLabelNode->myBrother = currentLnp; // May be NULL.
childLabelNode->Imported(IsImported());
//Inserts the label:
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// ------------------
-
-// Version: 0.0
-//Version Date Purpose
-// 0.0 Feb 6 1997 Creation
-// MSV 21.03.2003: protect against stack overflow in destructor
-
-
#include <TDF_LabelNode.hxx>
#include <TDF_Data.hxx>
#include <TDF_LabelNode.hxx>
#include <TDF_Data.hxx>
}
//=======================================================================
}
//=======================================================================
-//function : ~TDF_LabelNode
//purpose :
//=======================================================================
//purpose :
//=======================================================================
-TDF_LabelNode::~TDF_LabelNode()
+void TDF_LabelNode::Destroy (const TDF_HAllocator& theAllocator)
{
// MSV 21.03.2003: do not delete brother, rather delete all children in a loop
// to avoid stack overflow
while (myFirstChild != NULL) {
TDF_LabelNode* aSecondChild = myFirstChild->Brother();
{
// MSV 21.03.2003: do not delete brother, rather delete all children in a loop
// to avoid stack overflow
while (myFirstChild != NULL) {
TDF_LabelNode* aSecondChild = myFirstChild->Brother();
+ myFirstChild->Destroy (theAllocator);
myFirstChild = aSecondChild;
}
myFirstAttribute.Nullify();
myFirstChild = aSecondChild;
}
myFirstAttribute.Nullify();
- myLastFoundChild = NULL; //jfa 10.01.2003
+ myFather = myBrother = myFirstChild = myLastFoundChild = NULL;
+ myTag = myFlags = 0;
+
+ // deallocate memory (does nothing for IncAllocator)
+ theAllocator->Free (this);
}
//=======================================================================
}
//=======================================================================
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// ------------------
-
-// Version: 0.0
-//Version Date Purpose
-// 0.0 Feb 6 1997 Creation
-
-//#include <TDF_Data.hxx>
-
#ifndef TDF_LabelNode_HeaderFile
#define TDF_LabelNode_HeaderFile
#include <TCollection_AsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_LabelNodePtr.hxx>
#ifndef TDF_LabelNode_HeaderFile
#define TDF_LabelNode_HeaderFile
#include <TCollection_AsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_LabelNodePtr.hxx>
-#include <NCollection_IncAllocator.hxx>
+#include <TDF_HAllocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
class TDF_Attribute;
class TDF_AttributeIterator;
class TDF_Attribute;
class TDF_AttributeIterator;
inline Standard_Boolean MayBeModified() const
{ return ((myFlags & TDF_LabelNodeMayModMsk) != 0); };
inline Standard_Boolean MayBeModified() const
{ return ((myFlags & TDF_LabelNodeMayModMsk) != 0); };
+ private :
+
+ // Memory management
+ DEFINE_NCOLLECTION_ALLOC
+
- TDF_LabelNode(TDF_Data* Data); // Useful for root node.
+ TDF_LabelNode(TDF_Data* Data);
- // Destructor
- ~TDF_LabelNode();
+ // Destructor and deallocator
+ void Destroy (const TDF_HAllocator& theAllocator);
- // Memory management
- void * operator new (size_t aSize,
- const Handle(NCollection_IncAllocator)& anAlloc)
- { return anAlloc -> Allocate (aSize); }
-#if !defined(__BORLANDC__) && (!defined(__SUNPRO_CC) || (__SUNPRO_CC > 0x530))
- void operator delete (void* theAddress,
- const Handle(NCollection_IncAllocator)& anAlloc)
- {
- }
-#endif
- void operator delete(void *) { }
- // nothing to do in operator delete since IncAllocator does not need it
// Public Friends
// --------------------------------------------------------------------------
// Public Friends
// --------------------------------------------------------------------------
- void* operator new(size_t);
-
// Private Methods
// --------------------------------------------------------------------------
// Private Methods
// --------------------------------------------------------------------------