Posted By: Benni003
Set struct array free - 02/03/14 18:41
Hi I just need to now how to set the memory area free.
I know I can use the free() funktion to do that. But how I have to write for a pointer array?
Here is the code:
I think free(graph.points); is incorrect to set the complete pointer array free, or is it right?
I know I can use the free() funktion to do that. But how I have to write for a pointer array?
Here is the code:
Code:
typedef struct GRAPH { POINT **points; // Knoten-Array } GRAPH; void f_create_graph(var num_points) { // create GRAPH* graph = malloc(sizeof(GRAPH)); graph.points = (POINT **)malloc(num_points * num_points * sizeof(POINT*)); // set free free(graph.points); free(graph); }
I think free(graph.points); is incorrect to set the complete pointer array free, or is it right?