Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Add a fresh pointer member inside Point_set_scene_item class, Heap corruption when destruction

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Add a fresh pointer member inside Point_set_scene_item class, Heap corruption when destruction


Chronological Thread 
  • From: "Laurent Rineau (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Add a fresh pointer member inside Point_set_scene_item class, Heap corruption when destruction
  • Date: Tue, 21 Dec 2010 08:14:47 +0100
  • Organization: GeometryFactory

Le mardi 21 décembre 2010 04:51:49, cmodel a écrit :
> Here is the issue,
>
> I tried adding one pointer member, like std::vector *m_point2;
> inside Point_set_scene_item class,
>
> typedef CGAL::Triangulation_2 Triangulation2;
>
> typedef Triangulation2::Face_handle Face_handle;
> typedef Triangulation2::Finite_faces_iterator Finite_faces_iterator;
> typedef Triangulation2::Point Point2;
>
>
> then in destructor, add the following:
>
> Q_ASSERT(m_point2 != NULL);
> delete m_point2; m_point2 = NULL;

Replace by:

if(m_point_2) {
delete m_point2;
};

And add:

m_point2=NULL;

in the constructor.

> in bool Point_set_scene_item::read_xyz_point_set(std::istream& stream)
> code section, add the following:
>
> m_point2 = new std::vector;

Change that to:

if(m_point2==NULL)
m_point2 = new std::vector;
else
m_point2->clear();

> Then build the project, run, got " heap corruption debug error ", did I use
> wrong memory?

Did you clean the whole project before rebuilding it?

--
Laurent Rineau, PhD
Release Manager of the CGAL Project http://www.cgal.org/
R&D Engineer at GeometryFactory http://www.geometryfactory.com/



Archive powered by MHonArc 2.6.16.

Top of Page