mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-08-14 12:39:17 +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:
@@ -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;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Reference in New Issue
Block a user