aboutsummaryrefslogtreecommitdiff
path: root/src/cell.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-03-17 14:09:49 +0100
committerThomas White <taw@physics.org>2010-03-17 14:09:49 +0100
commit274a5e2803eb3afe0d53b27c6078ef4495d587a0 (patch)
treea1bc21d37e94ff5450cddc148cd33227b30f94ad /src/cell.c
parentf38be837bd33dfc4d98d251b2e81d5fa555a4f5c (diff)
Fix various memory leaks and tidy a few things
Diffstat (limited to 'src/cell.c')
-rw-r--r--src/cell.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cell.c b/src/cell.c
index 5747ed63..408b5bf3 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -262,11 +262,25 @@ static UnitCell *cell_new_from_axes(struct rvec as, struct rvec bs,
cell->cy = gsl_matrix_get(inv, 2, 1);
cell->cz = gsl_matrix_get(inv, 2, 2);
+ gsl_matrix_free(inv);
+
cell_update_crystallographic(cell);
return cell;
}
+UnitCell *cell_new_from_cell(UnitCell *orig)
+{
+ UnitCell *new;
+
+ new = malloc(sizeof(UnitCell));
+
+ *new = *orig;
+
+ return new;
+}
+
+
void cell_get_cartesian(UnitCell *cell,
double *ax, double *ay, double *az,
double *bx, double *by, double *bz,
@@ -321,6 +335,8 @@ void cell_get_reciprocal(UnitCell *cell,
*asz = gsl_matrix_get(inv, 2, 0);
*bsz = gsl_matrix_get(inv, 2, 1);
*csz = gsl_matrix_get(inv, 2, 2);
+
+ gsl_matrix_free(inv);
}