I have a struct that only contains pointers to memory that I\'ve allocated. Is there a way to recursively free each element that is a pointer rather than calling free on eac
You could calculate the size needed for all of them together and do one big malloc
sizeof(model)+sizeof(vertex)*nVertices... etc.
assign the result to mdl, result+sizeof(model) to model->vertices...
Then to free it is just one free.
You may have to worry about alignment issues (depending on your platform) but that shouldn't be too tough to figure out. The other problem is that it is a much larger chunk which may present a problem if in a memory constrained environment.