Archived

This topic is now archived and is closed to further replies.

Ethan

Delete a structure

Recommended Posts

Ethan    122
I have a structure like this: typedef struct COLOR{ int r; int g; int b; int a; }COLOR; typedef struct VERTEX{ int x; int y; int z; COLOR color; }VERTEX; VERTEX *vVertex; and i can''t free the vVertex. Can somebody help me?

Share this post


Link to post
Share on other sites
baumep    375
Have you done sth. like

VERTEX *vVertex = new Vertex;
//...code....
if(vVertex) delete[] vVertx;

this?
You may get into trouble if you try to delete vVertx without initializing it/allocating memory for it as in the last line of your code you posted.
(new and delete equal malloc and free in c)

baumep

Share this post


Link to post
Share on other sites