aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-09-08 12:22:37 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:57 +0100
commitc81d04eb776260f4499f3f3824bc5d02e42ef58c (patch)
tree83a57f955a65d65e5c65016662f5a7230cc5fe0d /src
parent9526f8c65df5fdb21247b57cd414c258375dc798 (diff)
Fix unit cell point group memory leak
Diffstat (limited to 'src')
-rw-r--r--src/cell.c7
-rw-r--r--src/cell.h1
-rw-r--r--src/facetron.c2
-rw-r--r--src/index.c2
-rw-r--r--src/indexamajig.c4
-rw-r--r--src/pattern_sim.c2
-rw-r--r--src/process_hkl.c2
7 files changed, 14 insertions, 6 deletions
diff --git a/src/cell.c b/src/cell.c
index a13ad577..757ce649 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -86,6 +86,13 @@ UnitCell *cell_new()
}
+void cell_free(UnitCell *cell)
+{
+ free(cell->pointgroup);
+ free(cell);
+}
+
+
void cell_set_parameters(UnitCell *cell, double a, double b, double c,
double alpha, double beta, double gamma)
{
diff --git a/src/cell.h b/src/cell.h
index f44de74f..a4d32bf8 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -28,6 +28,7 @@ typedef struct _unitcell UnitCell;
extern UnitCell *cell_new(void);
extern UnitCell *cell_new_from_cell(UnitCell *orig);
+extern void cell_free(UnitCell *cell);
/* Lengths in m, angles in radians */
extern UnitCell *cell_new_from_parameters(double a, double b, double c,
diff --git a/src/facetron.c b/src/facetron.c
index 0c2b4d56..42589526 100644
--- a/src/facetron.c
+++ b/src/facetron.c
@@ -324,7 +324,7 @@ int main(int argc, char *argv[])
find_intersections(&image, cell, da, dw, &np, 1);
hdfile_close(hdfile);
- free(cell);
+ cell_free(cell);
free(filename);
free(image.data);
free(image.flags);
diff --git a/src/index.c b/src/index.c
index 16265865..b5d9da9e 100644
--- a/src/index.c
+++ b/src/index.c
@@ -176,6 +176,6 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod indm,
done:
for ( i=0; i<image->ncells; i++ ) {
- free(image->candidate_cells[i]);
+ cell_free(image->candidate_cells[i]);
}
}
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 32fb9012..bfce345c 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -433,7 +433,7 @@ static struct process_result process_image(struct process_args *pargs)
free(simage);
/* Only free cell if found */
- free(image.indexed_cell);
+ cell_free(image.indexed_cell);
done:
free(image.data);
@@ -865,7 +865,7 @@ int main(int argc, char *argv[])
free(prefix);
free(det->panels);
free(det);
- free(cell);
+ cell_free(cell);
fclose(fh);
STATUS("There were %i images.\n", n_images);
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 616eec2c..23da9b86 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -477,7 +477,7 @@ skip:
free(image.det->panels);
free(image.det);
free(powder);
- free(cell);
+ cell_free(cell);
free(intensities);
free(outfile);
free(filename);
diff --git a/src/process_hkl.c b/src/process_hkl.c
index 32529b6b..67e17212 100644
--- a/src/process_hkl.c
+++ b/src/process_hkl.c
@@ -687,7 +687,7 @@ int main(int argc, char *argv[])
free(model);
free(counts);
free(output);
- free(cell);
+ cell_free(cell);
return 0;
}