diff options
author | Thomas White <taw@physics.org> | 2021-11-25 16:34:53 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-11-25 16:34:53 +0100 |
commit | a509bb92bfe3ba9525e6e348a5674c6df1f17c15 (patch) | |
tree | 42e396aceb80f8499cbdcec3e8f871ed898009dd /src | |
parent | f5d198b468d3e2c1bdece65ff5106c1989aee3c0 (diff) |
partialator: Use image_free() to avoid memory leaks
Requires that the array of crystals isn't allocated on the stack.
Diffstat (limited to 'src')
-rw-r--r-- | src/partialator.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/partialator.c b/src/partialator.c index c6f1c085..6a441d45 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -1607,8 +1607,8 @@ int main(int argc, char *argv[]) crystal_set_image(cr, image_for_crystal); *image_for_crystal = *image; image_for_crystal->n_crystals = 1; - image_for_crystal->crystals = &crystals[n_crystals]; - + image_for_crystal->crystals = malloc(sizeof(Crystal *)); + image_for_crystal->crystals[0] = cr; image_for_crystal->filename = strdup(image->filename); image_for_crystal->ev = safe_strdup(image->ev); image_for_crystal->detgeom = NULL; @@ -1823,13 +1823,7 @@ int main(int argc, char *argv[]) gsl_rng_free(rng); for ( icryst=0; icryst<n_crystals; icryst++ ) { struct image *image = crystal_get_image(crystals[icryst]); - spectrum_free(image->spectrum); - reflist_free(crystal_get_reflections(crystals[icryst])); - free(image->filename); - free(image->ev); - free(image); - cell_free(crystal_get_cell(crystals[icryst])); - crystal_free(crystals[icryst]); + image_free(image); } free_contribs(full); reflist_free(full); |