solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit 9388051808cf83773d99f4a1ba50a975b1738e7b
parent 790d023eea1e41e435e02d9a1e92e2d3f660d3ff
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 26 Sep 2017 11:33:52 +0200

Fix memory leaks

Anchors may be not properly release if an error occurs during the setup
of the entities.

Diffstat:
Msrc/solstice.c | 17+++++++++++++++++
Msrc/solstice_entity.c | 3---
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/solstice.c b/src/solstice.c @@ -115,6 +115,22 @@ clear_nodes(struct darray_nodes* nodes) darray_nodes_clear(nodes); } +static void +clear_anchors(struct htable_anchor* anchors) +{ + struct htable_anchor_iterator it, end; + ASSERT(anchors); + + htable_anchor_begin(anchors, &it); + htable_anchor_end(anchors, &end); + while(!htable_anchor_iterator_eq(&it, &end)) { + struct solstice_node* node = *htable_anchor_iterator_data_get(&it); + solstice_node_ref_put(node); + htable_anchor_iterator_next(&it); + } + htable_anchor_clear(anchors); +} + static res_T auto_look_at (struct ssol_scene* scn, @@ -676,6 +692,7 @@ solstice_release(struct solstice* solstice) clear_materials(&solstice->materials); clear_objects(&solstice->objects); clear_nodes(&solstice->roots); + clear_anchors(&solstice->anchors); /* Don't clear pivots, as they are cleared from some root */ if(solstice->ssol) SSOL(device_ref_put(solstice->ssol)); if(solstice->scene) SSOL(scene_ref_put(solstice->scene)); diff --git a/src/solstice_entity.c b/src/solstice_entity.c @@ -389,9 +389,6 @@ create_node res = solstice_node_add_child(node, tgt); if(res != RES_OK) goto error; - - solstice_node_ref_put(tgt); - tgt = NULL; } /* Setup children */