C
C++ Shark
Hi,
I have a structure which contains another structure in the following
way:
struct vertex {
double x, y, z; }
struct cube {
struct vertex v;
}
struct tree {
struct tree *child1, *child2;
struct cube c
}
now, i start with allocating memory to a tre pointer in the following
way:
struct tree *Mtree;
*Mtree is grown by allocating memory to child1 and child2.
now, i want to free up the memory used by some nodes of *Mtree. I
tried doing the following:
free(Mtree->c.v.x) which didn't work. If i try free(&(Mtree->c.v.x))
the program compiles, but i am still able to access the data at
Mtree->c.v.x, and so i don't know what to do. can anyone give me some
pointers on this issue? thanking you,
Craig
I have a structure which contains another structure in the following
way:
struct vertex {
double x, y, z; }
struct cube {
struct vertex v;
}
struct tree {
struct tree *child1, *child2;
struct cube c
}
now, i start with allocating memory to a tre pointer in the following
way:
struct tree *Mtree;
*Mtree is grown by allocating memory to child1 and child2.
now, i want to free up the memory used by some nodes of *Mtree. I
tried doing the following:
free(Mtree->c.v.x) which didn't work. If i try free(&(Mtree->c.v.x))
the program compiles, but i am still able to access the data at
Mtree->c.v.x, and so i don't know what to do. can anyone give me some
pointers on this issue? thanking you,
Craig