Skip to content
Snippets Groups Projects
Commit d50ddaf4 authored by tjfriedl's avatar tjfriedl
Browse files

Merge branch 'groundstation_gui_fixes' into 'master'

Finished free_graph method, needs testing implementation

See merge request !96
parents 74fde5a5 6c39ab8b
No related branches found
No related tags found
3 merge requests!104adding cflib to this branch,!103Updating develop to current state of master branch,!96Finished free_graph method, needs testing implementation
......@@ -27,6 +27,31 @@ struct computation_graph *create_graph() {
return the_graph;
}
struct computation_graph free_graph(struct computation_graph *graph) {
if (graph == NULL) return; // Do nothing if memory has already been cleared
for (int i = 0; i < graph->size; i++) {
if (graph_node_exists(graph, i)) {
struct graph_node *node = &graph->nodes[i];
// THESE ARE SEPERATED TO TEST FOR NOW -> There's gotta be a more concise way to do this.
if (node->name != NULL) free(node->name);
if (node->state != NULL) free(node->state);
if (node->output_values != NULL) free(node->output_values);
if (node->param_values != NULL) free(node->param_values);
if (node->input_srcs != NULL) free(node->input_srcs);
}
}
// These need to be tested as well... should just be able to be grouped together... right?
if (graph->nodes != NULL) free(graph->nodes);
if (graph->node_existence != NULL) free(graph->node_existence);
// Finally...
free(graph);
}
static void reset_node_rec(struct computation_graph* graph, int node_id, int depth) {
if (depth > GRAPH_MAX_DEPTH) {
return;
......
......@@ -67,6 +67,11 @@ struct graph_node {
*/
struct computation_graph *create_graph();
/**
* Frees memory allocated for computation graph
*/
struct computation_graph free_graph(struct computation_graph *graph);
/*
* Defines which node's output gets its value passed into the input of a different node.
* Will call reset for each node which was previously orphaned, but is now connected to the graph
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment