Changeset ececad


Ignore:
Timestamp:
Feb 26, 2010, 10:01:30 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
031ec24
Parents:
edbe74
git-author:
Frederik Heber <heber@…> (02/26/10 09:59:15)
git-committer:
Frederik Heber <heber@…> (02/26/10 10:01:30)
Message:

MEMLEAK: TesselPoints and Vectors created during TesselationBoundaryTriangleTest::setUp() would not get free'd.

  • Delete of triangle only destroys triangle, its lines and edges, not the TesselPoints
  • New array *tesselpoints[3] introduced, which stores pointers to the created TesselPoints and free's them in tearDown().
  • Allocated Vector's for the TesselPoints have to be deleted as well, as the TesselPoints normally only receive referencing pointers.
Location:
molecuilder/src/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/unittests/tesselation_boundarytriangleunittest.cpp

    redbe74 rececad  
    3535
    3636  // create nodes
    37   TesselPoint *Walker = NULL;
    38   Walker = new TesselPoint;
    39   Walker->node = new Vector(0., 0., 0.);
    40   Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
    41   strcpy(Walker->Name, "1");
    42   Walker->nr = 1;
    43   points[0] = new BoundaryPointSet(Walker);
    44   Walker = new TesselPoint;
    45   Walker->node = new Vector(0., 1., 0.);
    46   Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
    47   strcpy(Walker->Name, "2");
    48   Walker->nr = 2;
    49   points[1] = new BoundaryPointSet(Walker);
    50   Walker = new TesselPoint;
    51   Walker->node = new Vector(1., 0., 0.);
    52   Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
    53   strcpy(Walker->Name, "3");
    54   Walker->nr = 3;
    55   points[2] = new BoundaryPointSet(Walker);
     37  tesselpoints[0] = new TesselPoint;
     38  tesselpoints[0]->node = new Vector(0., 0., 0.);
     39  tesselpoints[0]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
     40  strcpy(tesselpoints[0]->Name, "1");
     41  tesselpoints[0]->nr = 1;
     42  points[0] = new BoundaryPointSet(tesselpoints[0]);
     43  tesselpoints[1] = new TesselPoint;
     44  tesselpoints[1]->node = new Vector(0., 1., 0.);
     45  tesselpoints[1]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
     46  strcpy(tesselpoints[1]->Name, "2");
     47  tesselpoints[1]->nr = 2;
     48  points[1] = new BoundaryPointSet(tesselpoints[1]);
     49  tesselpoints[2] = new TesselPoint;
     50  tesselpoints[2] ->node = new Vector(1., 0., 0.);
     51  tesselpoints[2] ->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
     52  strcpy(tesselpoints[2] ->Name, "3");
     53  tesselpoints[2] ->nr = 3;
     54  points[2] = new BoundaryPointSet(tesselpoints[2] );
    5655
    5756  // create line
     
    6968{
    7069  delete(triangle);
     70  for (int i=0;i<3;++i) {
     71    // TesselPoint does not delete its vector as it only got a reference
     72    delete tesselpoints[i]->node;
     73    delete tesselpoints[i];
     74  }
    7175  MemoryUsageObserver::purgeInstance();
    7276  logger::purgeInstance();
  • molecuilder/src/unittests/tesselation_boundarytriangleunittest.hpp

    redbe74 rececad  
    3535      class BoundaryLineSet *lines[3];
    3636      class BoundaryPointSet *points[3];
     37      class TesselPoint *tesselpoints[3];
    3738      LinkedNodes Corners;
    3839};
Note: See TracChangeset for help on using the changeset viewer.