mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-08-09 07:20:52 +08:00
Coding - Remove redundant null checks before deallocation (#1077)
In C++, delete/delete[] on nullptr and free(NULL) are guaranteed no-ops. This removes redundant null-check guards before these calls across 39 files, reducing code noise without behavioral change. Also simplifies map value cleanup in BRepClass3d_SolidExplorer by using iterator reference instead of redundant hash lookups.
This commit is contained in:
@@ -286,11 +286,8 @@ void TNaming_NamedShape::Clear()
|
||||
{
|
||||
q = p;
|
||||
p = p->nextSameAttribute;
|
||||
if (q != nullptr)
|
||||
{
|
||||
delete q;
|
||||
q = nullptr;
|
||||
}
|
||||
delete q;
|
||||
q = nullptr;
|
||||
}
|
||||
|
||||
myNode = nullptr;
|
||||
@@ -352,11 +349,8 @@ bool TNaming_NamedShape::AfterUndo(const occ::handle<TDF_AttributeDelta>& anAttD
|
||||
{
|
||||
q = p;
|
||||
p = p->nextSameAttribute;
|
||||
if (q != nullptr)
|
||||
{
|
||||
delete q;
|
||||
q = nullptr;
|
||||
}
|
||||
delete q;
|
||||
q = nullptr;
|
||||
}
|
||||
|
||||
myNode = nullptr;
|
||||
|
||||
@@ -118,8 +118,7 @@ LDOMBasicString::~LDOMBasicString()
|
||||
{
|
||||
if (myType == LDOM_AsciiFree)
|
||||
{
|
||||
if (myVal.ptr)
|
||||
delete[] (char*)myVal.ptr;
|
||||
delete[] (char*)myVal.ptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +129,7 @@ LDOMBasicString::~LDOMBasicString()
|
||||
|
||||
LDOMBasicString& LDOMBasicString::operator=(const LDOM_NullPtr*)
|
||||
{
|
||||
if (myType == LDOM_AsciiFree && myVal.ptr)
|
||||
if (myType == LDOM_AsciiFree)
|
||||
delete[] (char*)myVal.ptr;
|
||||
myType = LDOM_NULL;
|
||||
myVal.ptr = nullptr;
|
||||
@@ -148,7 +147,7 @@ LDOMBasicString& LDOMBasicString::operator=(const LDOMBasicString& anOther)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
if (myType == LDOM_AsciiFree && myVal.ptr)
|
||||
if (myType == LDOM_AsciiFree)
|
||||
delete[] (char*)myVal.ptr;
|
||||
myType = anOther.Type();
|
||||
switch (myType)
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
|
||||
LDOMParser::~LDOMParser()
|
||||
{
|
||||
if (myReader)
|
||||
delete myReader;
|
||||
delete myReader;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -145,8 +144,7 @@ bool LDOMParser::parse(std::istream& anInput, const bool theTagPerStep, const bo
|
||||
myError.Clear();
|
||||
|
||||
// Create the Reader instance
|
||||
if (myReader)
|
||||
delete myReader;
|
||||
delete myReader;
|
||||
myReader = new LDOM_XmlReader(myDocument, myError, theTagPerStep);
|
||||
|
||||
// Parse
|
||||
|
||||
@@ -254,8 +254,7 @@ LDOM_MemManager::LDOM_MemManager(const int aBlockSize)
|
||||
LDOM_MemManager::~LDOM_MemManager()
|
||||
{
|
||||
delete myFirstBlock;
|
||||
if (myHashTable)
|
||||
delete myHashTable;
|
||||
delete myHashTable;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -177,11 +177,7 @@ LDOM_XmlWriter::LDOM_XmlWriter(const char* theEncoding)
|
||||
LDOM_XmlWriter::~LDOM_XmlWriter()
|
||||
{
|
||||
delete[] myEncodingName;
|
||||
|
||||
if (myABuffer != nullptr)
|
||||
{
|
||||
delete[] myABuffer;
|
||||
}
|
||||
delete[] myABuffer;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
@@ -417,10 +413,7 @@ void LDOM_XmlWriter::WriteAttribute(Standard_OStream& theOStream, const LDOM_Nod
|
||||
aLength = (int)(20 + strlen(aName));
|
||||
if (aLength > myABufferLen)
|
||||
{
|
||||
if (myABuffer != nullptr)
|
||||
{
|
||||
delete[] myABuffer;
|
||||
}
|
||||
delete[] myABuffer;
|
||||
|
||||
myABuffer = new char[aLength + 1];
|
||||
myABufferLen = aLength;
|
||||
@@ -452,10 +445,7 @@ void LDOM_XmlWriter::WriteAttribute(Standard_OStream& theOStream, const LDOM_Nod
|
||||
|
||||
if (aLength > myABufferLen)
|
||||
{
|
||||
if (myABuffer != nullptr)
|
||||
{
|
||||
delete[] myABuffer;
|
||||
}
|
||||
delete[] myABuffer;
|
||||
|
||||
myABuffer = new char[aLength + 1];
|
||||
myABufferLen = aLength;
|
||||
|
||||
@@ -102,11 +102,8 @@ const char* Interface_MSG::Value() const
|
||||
|
||||
void Interface_MSG::Destroy()
|
||||
{
|
||||
if (theval)
|
||||
{
|
||||
delete[] theval;
|
||||
theval = nullptr;
|
||||
}
|
||||
delete[] theval;
|
||||
theval = nullptr;
|
||||
}
|
||||
|
||||
Interface_MSG::operator const char*() const
|
||||
|
||||
@@ -174,8 +174,7 @@ void Interface_ParamSet::Destroy()
|
||||
// if (!thenext.IsNull()) thenext->Destroy();
|
||||
thenext.Nullify();
|
||||
// "Manual" destruction (direct memory management)
|
||||
if (theval)
|
||||
delete[] theval;
|
||||
delete[] theval;
|
||||
theval = nullptr;
|
||||
thelist->Clear();
|
||||
thelist.Nullify();
|
||||
|
||||
@@ -530,11 +530,8 @@ void Draw_Viewer::RemoveView(const int id)
|
||||
{
|
||||
if (Draw_Batch)
|
||||
return;
|
||||
if (myViews[id])
|
||||
{
|
||||
delete myViews[id];
|
||||
myViews[id] = nullptr;
|
||||
}
|
||||
delete myViews[id];
|
||||
myViews[id] = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
@@ -724,11 +721,8 @@ void Draw_Viewer::DeleteView(const int id)
|
||||
{
|
||||
if (Draw_Batch)
|
||||
return;
|
||||
if (myViews[id] != nullptr)
|
||||
{
|
||||
delete myViews[id];
|
||||
myViews[id] = nullptr;
|
||||
}
|
||||
delete myViews[id];
|
||||
myViews[id] = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -557,11 +557,8 @@ static void printtolblend(Draw_Interpretor& di)
|
||||
|
||||
static int MKEVOL(Draw_Interpretor& di, int narg, const char** a)
|
||||
{
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
}
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
printtolblend(di);
|
||||
if (narg < 3)
|
||||
return 1;
|
||||
@@ -632,18 +629,12 @@ static int BUILDEVOL(Draw_Interpretor& di, int, const char**)
|
||||
{
|
||||
TopoDS_Shape result = Rake->Shape();
|
||||
DBRep::Set(name, result);
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
return 0;
|
||||
}
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,11 +142,8 @@ int bop(Draw_Interpretor& di, int n, const char** a)
|
||||
aLC.Append(aS1);
|
||||
aLC.Append(aS2);
|
||||
//
|
||||
if (pPF != nullptr)
|
||||
{
|
||||
delete pPF;
|
||||
pPF = nullptr;
|
||||
}
|
||||
delete pPF;
|
||||
pPF = nullptr;
|
||||
occ::handle<NCollection_BaseAllocator> aAL = NCollection_BaseAllocator::CommonBaseAllocator();
|
||||
pPF = new BOPAlgo_PaveFiller(aAL);
|
||||
//
|
||||
|
||||
@@ -147,11 +147,8 @@ static int tolblend(Draw_Interpretor& di, int narg, const char** a)
|
||||
|
||||
static int BLEND(Draw_Interpretor& di, int narg, const char** a)
|
||||
{
|
||||
if (Rakk != nullptr)
|
||||
{
|
||||
delete Rakk;
|
||||
Rakk = nullptr;
|
||||
}
|
||||
delete Rakk;
|
||||
Rakk = nullptr;
|
||||
printtolblend(di);
|
||||
if (narg < 5)
|
||||
return 1;
|
||||
@@ -276,11 +273,8 @@ static int CheckHist(Draw_Interpretor& di, int, const char**)
|
||||
|
||||
static int MKEVOL(Draw_Interpretor& di, int narg, const char** a)
|
||||
{
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
}
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
printtolblend(di);
|
||||
if (narg < 3)
|
||||
return 1;
|
||||
@@ -343,18 +337,12 @@ static int BUILDEVOL(Draw_Interpretor& di, int, const char**)
|
||||
{
|
||||
TopoDS_Shape result = Rake->Shape();
|
||||
DBRep::Set(name, result);
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (Rake != nullptr)
|
||||
{
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
return 0;
|
||||
}
|
||||
delete Rake;
|
||||
Rake = nullptr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -467,11 +467,7 @@ int thrusections(Draw_Interpretor& di, int n, const char** a)
|
||||
bool issolid = (Draw::Atoi(a[index]) == 1);
|
||||
bool isruled = (Draw::Atoi(a[index + 1]) == 1);
|
||||
|
||||
if (Generator != nullptr)
|
||||
{
|
||||
delete Generator;
|
||||
Generator = nullptr;
|
||||
}
|
||||
delete Generator;
|
||||
Generator = new BRepOffsetAPI_ThruSections(issolid, isruled);
|
||||
bool IsMutableInput = true;
|
||||
int NbEdges = 0;
|
||||
@@ -568,11 +564,8 @@ static int mksweep(Draw_Interpretor& di, int n, const char** a)
|
||||
TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE);
|
||||
if (Spine.IsNull())
|
||||
return 1;
|
||||
if (Sweep != nullptr)
|
||||
{
|
||||
delete Sweep;
|
||||
Sweep = nullptr;
|
||||
}
|
||||
delete Sweep;
|
||||
Sweep = nullptr;
|
||||
|
||||
if (n > 2 && n <= 5)
|
||||
{
|
||||
|
||||
@@ -60,11 +60,8 @@ static void printtolblend(Draw_Interpretor& di)
|
||||
|
||||
static int VBLEND(Draw_Interpretor& di, int narg, const char** a)
|
||||
{
|
||||
if (Rakk != nullptr)
|
||||
{
|
||||
delete Rakk;
|
||||
Rakk = nullptr;
|
||||
}
|
||||
delete Rakk;
|
||||
Rakk = nullptr;
|
||||
printtolblend(di);
|
||||
if (narg < 5)
|
||||
return 1;
|
||||
|
||||
@@ -365,11 +365,8 @@ void Poly_Triangulation::SetCachedMinMax(const Bnd_Box& theBox)
|
||||
|
||||
void Poly_Triangulation::unsetCachedMinMax()
|
||||
{
|
||||
if (myCachedMinMax != nullptr)
|
||||
{
|
||||
delete myCachedMinMax;
|
||||
myCachedMinMax = nullptr;
|
||||
}
|
||||
delete myCachedMinMax;
|
||||
myCachedMinMax = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -52,9 +52,8 @@ void NCollection_BaseMap::EndResize(const int theNbBuckets,
|
||||
NCollection_ListNode** data2) noexcept
|
||||
{
|
||||
(void)theNbBuckets; // obsolete parameter
|
||||
if (myData1)
|
||||
Standard::Free(myData1);
|
||||
if (myData2 && isDouble)
|
||||
Standard::Free(myData1);
|
||||
if (isDouble)
|
||||
Standard::Free(myData2);
|
||||
myNbBuckets = N;
|
||||
myData1 = data1;
|
||||
@@ -90,10 +89,8 @@ void NCollection_BaseMap::Destroy(NCollection_DelMapNode fDel, bool doReleaseMem
|
||||
}
|
||||
if (doReleaseMemory)
|
||||
{
|
||||
if (myData1)
|
||||
Standard::Free(myData1);
|
||||
if (myData2)
|
||||
Standard::Free(myData2);
|
||||
Standard::Free(myData1);
|
||||
Standard::Free(myData2);
|
||||
myData1 = myData2 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ private:
|
||||
//! Destructor deletes the object
|
||||
~Ptr() override
|
||||
{
|
||||
if (myPtr)
|
||||
delete myPtr;
|
||||
delete myPtr;
|
||||
myPtr = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,7 @@ void* NCollection_HeapAllocator::Allocate(const size_t theSize)
|
||||
|
||||
void NCollection_HeapAllocator::Free(void* anAddress)
|
||||
{
|
||||
if (anAddress)
|
||||
free(anAddress);
|
||||
free(anAddress);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -31,11 +31,8 @@ NCollection_UtfStringTool::~NCollection_UtfStringTool()
|
||||
|
||||
wchar_t* NCollection_UtfStringTool::FromLocale(const char* theString)
|
||||
{
|
||||
if (myWideBuffer != nullptr)
|
||||
{
|
||||
delete[] myWideBuffer;
|
||||
myWideBuffer = nullptr;
|
||||
}
|
||||
delete[] myWideBuffer;
|
||||
myWideBuffer = nullptr;
|
||||
|
||||
#if defined(_WIN32)
|
||||
// use WinAPI
|
||||
|
||||
@@ -165,8 +165,7 @@ void OSD_Environment::Build()
|
||||
putenv(buffer[index]);
|
||||
|
||||
// then (and only then!) free old entry, if existed
|
||||
if (old_value)
|
||||
free(old_value);
|
||||
free(old_value);
|
||||
|
||||
// check the result
|
||||
char* result = getenv(myName.ToCString());
|
||||
|
||||
@@ -196,12 +196,9 @@ const char* OSD_SharedLibrary::DlError() const
|
||||
|
||||
void OSD_SharedLibrary::Destroy()
|
||||
{
|
||||
if (myName != nullptr)
|
||||
{
|
||||
delete[] myName;
|
||||
myName = nullptr;
|
||||
myHandle = nullptr;
|
||||
}
|
||||
delete[] myName;
|
||||
myName = nullptr;
|
||||
myHandle = nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -253,9 +250,7 @@ void OSD_SharedLibrary ::SetName(const char* const aName)
|
||||
OSD_Path path(aName);
|
||||
TCollection_AsciiString name(aName);
|
||||
|
||||
if (myName != NULL)
|
||||
|
||||
delete[] myName;
|
||||
delete[] myName;
|
||||
|
||||
myName = new char[strlen(aName) + 1];
|
||||
|
||||
@@ -343,10 +338,7 @@ const char* OSD_SharedLibrary ::DlError() const
|
||||
|
||||
void OSD_SharedLibrary ::Destroy()
|
||||
{
|
||||
|
||||
if (myName != NULL)
|
||||
delete[] myName;
|
||||
|
||||
delete[] myName;
|
||||
} // end OSD_SharedLibrary :: Destroy
|
||||
|
||||
#endif
|
||||
|
||||
@@ -360,11 +360,8 @@ void BOPAlgo_BOP::Perform(const Message_ProgressRange& theRange)
|
||||
//
|
||||
if (myEntryPoint == 1)
|
||||
{
|
||||
if (myPaveFiller)
|
||||
{
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
//
|
||||
aAllocator = NCollection_BaseAllocator::CommonBaseAllocator();
|
||||
|
||||
@@ -80,11 +80,8 @@ BOPAlgo_Builder::~BOPAlgo_Builder()
|
||||
{
|
||||
if (myEntryPoint == 1)
|
||||
{
|
||||
if (myPaveFiller)
|
||||
{
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,11 +170,8 @@ void BOPAlgo_Builder::Perform(const Message_ProgressRange& theRange)
|
||||
//
|
||||
if (myEntryPoint == 1)
|
||||
{
|
||||
if (myPaveFiller)
|
||||
{
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
//
|
||||
occ::handle<NCollection_BaseAllocator> aAllocator =
|
||||
|
||||
@@ -53,11 +53,8 @@ void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
|
||||
//
|
||||
if (myEntryPoint == 1)
|
||||
{
|
||||
if (myPaveFiller)
|
||||
{
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
//
|
||||
occ::handle<NCollection_BaseAllocator> aAllocator =
|
||||
|
||||
@@ -135,16 +135,10 @@ bool BOPAlgo_PaveFiller::IsPrimary() const
|
||||
void BOPAlgo_PaveFiller::Clear()
|
||||
{
|
||||
BOPAlgo_Algo::Clear();
|
||||
if (myIterator)
|
||||
{
|
||||
delete myIterator;
|
||||
myIterator = nullptr;
|
||||
}
|
||||
if (myDS)
|
||||
{
|
||||
delete myDS;
|
||||
myDS = nullptr;
|
||||
}
|
||||
delete myIterator;
|
||||
myIterator = nullptr;
|
||||
delete myDS;
|
||||
myDS = nullptr;
|
||||
myIncreasedSS.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +57,8 @@ void BOPAlgo_Splitter::Perform(const Message_ProgressRange& theRange)
|
||||
//
|
||||
if (myEntryPoint == 1)
|
||||
{
|
||||
if (myPaveFiller)
|
||||
{
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
delete myPaveFiller;
|
||||
myPaveFiller = nullptr;
|
||||
}
|
||||
//
|
||||
// prepare shapes for intersection
|
||||
|
||||
@@ -58,16 +58,13 @@ BRepAlgoAPI_BuilderAlgo::~BRepAlgoAPI_BuilderAlgo()
|
||||
void BRepAlgoAPI_BuilderAlgo::Clear()
|
||||
{
|
||||
BRepAlgoAPI_Algo::Clear();
|
||||
if (myDSFiller && myIsIntersectionNeeded)
|
||||
if (myIsIntersectionNeeded)
|
||||
{
|
||||
delete myDSFiller;
|
||||
myDSFiller = nullptr;
|
||||
}
|
||||
if (myBuilder)
|
||||
{
|
||||
delete myBuilder;
|
||||
myBuilder = nullptr;
|
||||
}
|
||||
delete myBuilder;
|
||||
myBuilder = nullptr;
|
||||
if (myHistory)
|
||||
myHistory.Nullify();
|
||||
|
||||
@@ -107,8 +104,7 @@ void BRepAlgoAPI_BuilderAlgo::IntersectShapes(const NCollection_List<TopoDS_Shap
|
||||
if (!myIsIntersectionNeeded)
|
||||
return;
|
||||
|
||||
if (myDSFiller)
|
||||
delete myDSFiller;
|
||||
delete myDSFiller;
|
||||
|
||||
// Create new Filler
|
||||
myDSFiller = new BOPAlgo_PaveFiller(myAllocator);
|
||||
|
||||
@@ -33,29 +33,17 @@ static bool GLOBAL_FDSCNX_prepared = false;
|
||||
|
||||
void FDSCNX_Close()
|
||||
{
|
||||
if (GLOBAL_elf1)
|
||||
{
|
||||
delete GLOBAL_elf1;
|
||||
GLOBAL_elf1 = nullptr;
|
||||
}
|
||||
delete GLOBAL_elf1;
|
||||
GLOBAL_elf1 = nullptr;
|
||||
//
|
||||
if (GLOBAL_elf2)
|
||||
{
|
||||
delete GLOBAL_elf2;
|
||||
GLOBAL_elf2 = nullptr;
|
||||
}
|
||||
delete GLOBAL_elf2;
|
||||
GLOBAL_elf2 = nullptr;
|
||||
//
|
||||
if (GLOBAL_fle)
|
||||
{
|
||||
delete GLOBAL_fle;
|
||||
GLOBAL_fle = nullptr;
|
||||
}
|
||||
delete GLOBAL_fle;
|
||||
GLOBAL_fle = nullptr;
|
||||
//
|
||||
if (GLOBAL_los)
|
||||
{
|
||||
delete GLOBAL_los;
|
||||
GLOBAL_los = nullptr;
|
||||
}
|
||||
delete GLOBAL_los;
|
||||
GLOBAL_los = nullptr;
|
||||
//
|
||||
GLOBAL_FDSCNX_prepared = false;
|
||||
}
|
||||
|
||||
@@ -37,17 +37,11 @@ static occ::handle<TopOpeBRepDS_HDataStructure>* Ghds;
|
||||
|
||||
void FDSSDM_Close()
|
||||
{
|
||||
if (Gps1)
|
||||
{
|
||||
delete Gps1;
|
||||
Gps1 = nullptr;
|
||||
}
|
||||
delete Gps1;
|
||||
Gps1 = nullptr;
|
||||
//
|
||||
if (Gps2)
|
||||
{
|
||||
delete Gps2;
|
||||
Gps2 = nullptr;
|
||||
}
|
||||
delete Gps2;
|
||||
Gps2 = nullptr;
|
||||
}
|
||||
|
||||
// modified by NIZNHY-PKV Sun Dec 15 17:56:02 2002 t
|
||||
|
||||
@@ -59,11 +59,8 @@ void LocOpe_CSIntersector::Init(const TopoDS_Shape& S)
|
||||
{
|
||||
myDone = false;
|
||||
myShape = S;
|
||||
if (myPoints != nullptr)
|
||||
{
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints = nullptr;
|
||||
}
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints = nullptr;
|
||||
myNbelem = 0;
|
||||
}
|
||||
|
||||
@@ -78,10 +75,7 @@ void LocOpe_CSIntersector::Perform(const NCollection_Sequence<gp_Lin>& Slin)
|
||||
myDone = false;
|
||||
|
||||
myNbelem = Slin.Length();
|
||||
if (myPoints != nullptr)
|
||||
{
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
}
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints =
|
||||
(NCollection_Sequence<LocOpe_PntFace>*)new NCollection_Sequence<LocOpe_PntFace>[myNbelem];
|
||||
|
||||
@@ -115,10 +109,7 @@ void LocOpe_CSIntersector::Perform(const NCollection_Sequence<gp_Circ>& Scir)
|
||||
myDone = false;
|
||||
|
||||
myNbelem = Scir.Length();
|
||||
if (myPoints != nullptr)
|
||||
{
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
}
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints =
|
||||
(NCollection_Sequence<LocOpe_PntFace>*)new NCollection_Sequence<LocOpe_PntFace>[myNbelem];
|
||||
|
||||
@@ -156,10 +147,7 @@ void LocOpe_CSIntersector::Perform(const NCollection_Sequence<occ::handle<Geom_C
|
||||
myDone = false;
|
||||
|
||||
myNbelem = Scur.Length();
|
||||
if (myPoints != nullptr)
|
||||
{
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
}
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints =
|
||||
(NCollection_Sequence<LocOpe_PntFace>*)new NCollection_Sequence<LocOpe_PntFace>[myNbelem];
|
||||
|
||||
@@ -222,11 +210,8 @@ const LocOpe_PntFace& LocOpe_CSIntersector::Point(const int I, const int Index)
|
||||
|
||||
void LocOpe_CSIntersector::Destroy()
|
||||
{
|
||||
if (myPoints != nullptr)
|
||||
{
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints = nullptr;
|
||||
}
|
||||
delete[] (NCollection_Sequence<LocOpe_PntFace>*)myPoints;
|
||||
myPoints = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -1248,10 +1248,7 @@ void GeomFill_ConstrainedFilling::PerformS1()
|
||||
// Un petit menage
|
||||
for (i = 0; i <= 3; i++)
|
||||
{
|
||||
if (nt[i])
|
||||
{
|
||||
delete[] nt[i];
|
||||
}
|
||||
delete[] nt[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +57,11 @@ static int NbPOnV(const occ::handle<Adaptor3d_Surface>& S)
|
||||
void IntPatch_Polyhedron::Destroy()
|
||||
{
|
||||
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
|
||||
if (C_MyPnts)
|
||||
delete[] CMyPnts;
|
||||
delete[] CMyPnts;
|
||||
double* CMyU = (double*)C_MyU;
|
||||
if (C_MyU)
|
||||
delete[] CMyU;
|
||||
delete[] CMyU;
|
||||
double* CMyV = (double*)C_MyV;
|
||||
if (C_MyV)
|
||||
delete[] CMyV;
|
||||
delete[] CMyV;
|
||||
C_MyPnts = C_MyU = C_MyV = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -2392,11 +2392,8 @@ void IntPatch_PrmPrmIntersection::Perform(const occ::handle<Adaptor3d_Surface>&
|
||||
done = Interference.IsDone();
|
||||
if (!done)
|
||||
{
|
||||
if (pInterference)
|
||||
{
|
||||
delete pInterference;
|
||||
pInterference = nullptr;
|
||||
}
|
||||
delete pInterference;
|
||||
pInterference = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,11 +30,8 @@ IntPatch_PrmPrmIntersection_T3Bits::IntPatch_PrmPrmIntersection_T3Bits(const int
|
||||
|
||||
IntPatch_PrmPrmIntersection_T3Bits::~IntPatch_PrmPrmIntersection_T3Bits()
|
||||
{
|
||||
if (p)
|
||||
{
|
||||
delete[] p;
|
||||
p = nullptr;
|
||||
}
|
||||
delete[] p;
|
||||
p = nullptr;
|
||||
}
|
||||
|
||||
void IntPatch_PrmPrmIntersection_T3Bits::ResetAnd()
|
||||
|
||||
@@ -180,8 +180,7 @@ void IntPolyh_Intersection::Perform(const NCollection_Array1<double>& theUPars1,
|
||||
{
|
||||
// Intersection not done
|
||||
myIsDone = false;
|
||||
if (pMaillageStd)
|
||||
delete pMaillageStd;
|
||||
delete pMaillageStd;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -228,19 +227,14 @@ void IntPolyh_Intersection::Perform(const NCollection_Array1<double>& theUPars1,
|
||||
}
|
||||
|
||||
// Clean up
|
||||
if (pMaillageFF)
|
||||
delete pMaillageFF;
|
||||
if (pMaillageFR)
|
||||
delete pMaillageFR;
|
||||
if (pMaillageRF)
|
||||
delete pMaillageRF;
|
||||
if (pMaillageRR)
|
||||
delete pMaillageRR;
|
||||
delete pMaillageFF;
|
||||
delete pMaillageFR;
|
||||
delete pMaillageRF;
|
||||
delete pMaillageRR;
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (pMaillageStd)
|
||||
delete pMaillageStd;
|
||||
delete pMaillageStd;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -484,11 +484,8 @@ void HLRBRep_Intersector::SimulateOnePoint(HLRBRep_EdgeData* theEdge1,
|
||||
void HLRBRep_Intersector::Load(HLRBRep_Surface* theSurface)
|
||||
{
|
||||
mySurface = theSurface;
|
||||
if (myPolyhedron != nullptr)
|
||||
{
|
||||
delete myPolyhedron;
|
||||
myPolyhedron = nullptr;
|
||||
}
|
||||
delete myPolyhedron;
|
||||
myPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
@@ -668,8 +665,8 @@ const IntCurveSurface_IntersectionSegment& HLRBRep_Intersector::CSSegment(const
|
||||
|
||||
void HLRBRep_Intersector::Destroy()
|
||||
{
|
||||
if (myPolyhedron != nullptr)
|
||||
delete myPolyhedron;
|
||||
delete myPolyhedron;
|
||||
myPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
/* ********************************************************************************
|
||||
|
||||
@@ -835,12 +835,9 @@ void BRepClass3d_SolidExplorer::Destroy()
|
||||
NCollection_DataMap<TopoDS_Shape, void*, TopTools_ShapeMapHasher>::Iterator iter(myMapOfInter);
|
||||
for (; iter.More(); iter.Next())
|
||||
{
|
||||
void* ptr = iter.Value();
|
||||
if (ptr)
|
||||
{
|
||||
delete (IntCurvesFace_Intersector*)ptr;
|
||||
myMapOfInter.ChangeFind(iter.Key()) = nullptr;
|
||||
}
|
||||
void*& aPtr = iter.ChangeValue();
|
||||
delete (IntCurvesFace_Intersector*)aPtr;
|
||||
aPtr = nullptr;
|
||||
}
|
||||
myMapOfInter.Clear();
|
||||
}
|
||||
@@ -860,12 +857,9 @@ void BRepClass3d_SolidExplorer::InitShape(const TopoDS_Shape& S)
|
||||
NCollection_DataMap<TopoDS_Shape, void*, TopTools_ShapeMapHasher>::Iterator iter(myMapOfInter);
|
||||
for (; iter.More(); iter.Next())
|
||||
{
|
||||
void* ptr = iter.Value();
|
||||
if (ptr)
|
||||
{
|
||||
delete (IntCurvesFace_Intersector*)ptr;
|
||||
myMapOfInter.ChangeFind(iter.Key()) = nullptr;
|
||||
}
|
||||
void*& aPtr = iter.ChangeValue();
|
||||
delete (IntCurvesFace_Intersector*)aPtr;
|
||||
aPtr = nullptr;
|
||||
}
|
||||
|
||||
myMapOfInter.Clear();
|
||||
|
||||
@@ -78,10 +78,7 @@ void BRepTopAdaptor_TopolTool::Initialize(const occ::handle<Adaptor3d_Surface>&
|
||||
TopoDS_Shape s_wnt = brhs->Face();
|
||||
s_wnt.Orientation(TopAbs_FORWARD);
|
||||
myFace = TopoDS::Face(s_wnt);
|
||||
if (myFClass2d != nullptr)
|
||||
{
|
||||
delete (BRepTopAdaptor_FClass2d*)myFClass2d;
|
||||
}
|
||||
delete (BRepTopAdaptor_FClass2d*)myFClass2d;
|
||||
myFClass2d = nullptr;
|
||||
myNbSamplesU = -1;
|
||||
myS = S;
|
||||
@@ -205,11 +202,8 @@ bool BRepTopAdaptor_TopolTool::IsThePointOn(const gp_Pnt2d& P,
|
||||
|
||||
void BRepTopAdaptor_TopolTool::Destroy()
|
||||
{
|
||||
if (myFClass2d != nullptr)
|
||||
{
|
||||
delete (BRepTopAdaptor_FClass2d*)myFClass2d;
|
||||
myFClass2d = nullptr;
|
||||
}
|
||||
delete (BRepTopAdaptor_FClass2d*)myFClass2d;
|
||||
myFClass2d = nullptr;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
@@ -44,11 +44,8 @@ public:
|
||||
//! Destructor
|
||||
~MeshVS_Buffer()
|
||||
{
|
||||
if (myDynData)
|
||||
{
|
||||
Standard::Free(myDynData);
|
||||
myDynData = nullptr;
|
||||
}
|
||||
Standard::Free(myDynData);
|
||||
myDynData = nullptr;
|
||||
}
|
||||
|
||||
//! Cast the buffer to the void pointer
|
||||
|
||||
@@ -608,11 +608,8 @@ void Image_AlienPixMap::Clear()
|
||||
myPalette = NULL;
|
||||
}
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
if (myLibImage != NULL)
|
||||
{
|
||||
free((void*)myLibImage);
|
||||
myLibImage = NULL;
|
||||
}
|
||||
free((void*)myLibImage);
|
||||
myLibImage = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user