I have two structures
struct SimpleXY
{
double x;
double y;
};
struct SimpleXyLink
{
int num_xy;
SimpleXY *simpleXyList
This entirely depends on how you allocated the memory. Freeing memory always has to echo the allocation.
That said, free
is almost certainly wrong in C++. Use new
/delete
instead of malloc
/free
.
Furthermore, it seems as though you’re allocating memory for several elements her (at least the name …List
implies this) so you will probably be better off using a C++ container structure, such as vector
or list
.