0022936: Memory leak in inc\MAT_Mat.gxx line
authorPawel, DBV <>
Fri, 17 Feb 2012 08:09:20 +0000 (08:09 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:32:39 +0000 (19:32 +0400)
src/MAT/MAT_Mat.gxx

index 5f7a1e9..4248b07 100755 (executable)
@@ -146,14 +146,9 @@ void MAT_Mat::CreateMat(Tool& atool)
   toleranceofconfusion = atool.ToleranceOfConfusion();
   NumberMaxOfIte       = noofedges*noofedges;
 
-  Standard_Integer* firstarea = new Standard_Integer[noofedges];
-  Standard_Integer* lastarea  = new Standard_Integer[noofedges];
-  Standard_Integer* noofarea  = new Standard_Integer[noofedges];
-
-  if (noofarea == 0) {
-    cout <<" Erreur d allocation "<<endl;
-    return;
-  }
+  TColStd_Array1OfInteger firstarea(0, noofedges);
+  TColStd_Array1OfInteger lastarea(0, noofedges);
+  TColStd_Array1OfInteger noofarea(0, noofedges);
 
   Standard_Integer  parama[2];
   Standard_Integer  paramb[2];
@@ -519,19 +514,19 @@ void MAT_Mat::CreateMat(Tool& atool)
       cout <<" A ELIMINER "<<endl;
 #endif 
        if(narea < 0) {
-         firstarea[++narea] = theedgelist->Index();
-         lastarea[narea] = firstarea[narea];
-         noofarea[narea] = 1;
+         firstarea(++narea) = theedgelist->Index();
+         lastarea(narea) = firstarea(narea);
+         noofarea(narea) = 1;
        }
        else {
-         if(theedgelist->Index() == lastarea[narea]+1) {
-           lastarea[narea]++;
-           noofarea[narea]++;
+         if(theedgelist->Index() == lastarea(narea)+1) {
+           lastarea(narea)++;
+           noofarea(narea)++;
          }
          else {
-           firstarea[++narea] = theedgelist->Index();
-           lastarea[narea] = firstarea[narea];
-           noofarea[narea] = 1;
+           firstarea(++narea) = theedgelist->Index();
+           lastarea(narea) = firstarea(narea);
+           noofarea(narea) = 1;
          }
        }
       }
@@ -543,10 +538,10 @@ void MAT_Mat::CreateMat(Tool& atool)
     
     compact = 0;
     if(narea > 0) {
-      if(lastarea[narea] == theedgelist->Number() && firstarea[0] == 1) {
-       firstarea[0] = firstarea[narea];
-       noofarea[0] = noofarea[0]+noofarea[narea];
-       compact = noofarea[narea];
+      if(lastarea(narea) == theedgelist->Number() && firstarea(0) == 1) {
+       firstarea(0) = firstarea(narea);
+       noofarea(0) = noofarea(0)+noofarea(narea);
+       compact = noofarea(narea);
        narea--;
       }
     }
@@ -572,12 +567,12 @@ void MAT_Mat::CreateMat(Tool& atool)
     beginbisector = noofbisectors;
     shift = 0;
     all = 0;
-    if(narea == 1 && noofarea[0] == theedgelist->Number()) all = 1;
+    if(narea == 1 && noofarea(0) == theedgelist->Number()) all = 1;
 
     for(i=0; i<narea; i++) {
       if(i == 1)shift = shift-compact;
       theedgelist->First();
-      edgetoremove = theedgelist->Brackets(firstarea[i]-shift);
+      edgetoremove = theedgelist->Brackets(firstarea(i)-shift);
       
       edgetoremove->FirstBisector()->EndPoint(edgetoremove
                                              ->IntersectionPoint());
@@ -605,7 +600,7 @@ void MAT_Mat::CreateMat(Tool& atool)
       bisectormap(noofbisectors)->AddBisector(edgetoremove
                                                 ->FirstBisector());
 
-      for(j=0; j<noofarea[i]; j++) {
+      for(j=0; j<noofarea(i); j++) {
        theedgelist->Unlink();
        theedgelist->Next();
        shift++;
@@ -614,7 +609,7 @@ void MAT_Mat::CreateMat(Tool& atool)
        cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<endl;
 #endif
 
-       if(all == 0 || j+1 != noofarea[i]) {
+       if(all == 0 || j+1 != noofarea(i)) {
          bisectormap(noofbisectors)->AddBisector(edgetoremove
                                                     ->SecondBisector());
        }
@@ -764,12 +759,6 @@ void MAT_Mat::CreateMat(Tool& atool)
     }
   }
   
-  //-------------------------------------
-  // Destruction des tableaux dynamiques.
-  //-------------------------------------
-  delete [] firstarea;
-  delete [] lastarea ;
-  delete [] noofarea ;
 }
 
 //========================================================================