Clarify memory management for selection values
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 1 Nov 2014 10:57:00 +0000 (12:57 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 28 Nov 2014 22:32:38 +0000 (23:32 +0100)
commit477759badb466447e994ab0c72af9e2cd18eb6ca
tree4265b8a21b59dfd7a40c9ece1f51b88b95ec94e5
parentc2a564d6b773408a5e497d59f7d8bc0c45b47876
Clarify memory management for selection values

Add asserts for cases where memory would be leaked when assigning the
storage pointer for gmx_ana_selvalue_t.  Add functions for cases where
the assignment is combined with some other operation that takes care of
the memory deallocation or ownership transfer to make the asserts not
give false positives.

The above clarifies the memory management and makes it less prone to
errors, but does not fix the memory leak that was revealed by "z of ..."
implementation.  To actually fix that, additionally split the logic for
freeing memory for gmx_ana_selparam_t, and call that also from the place
that earlier set the value pointer to NULL.

Move Doxygen documentation for some of the affected methods and their
neighbors to the header per newer guideline.

Add some extra debug output.

Change-Id: I4e5dfa1248a20cab8a242be7209b5b0779204e64
src/gromacs/selection/evaluate.cpp
src/gromacs/selection/selelem.cpp
src/gromacs/selection/selelem.h
src/gromacs/selection/selvalue.cpp
src/gromacs/selection/selvalue.h