diff options
Diffstat (limited to 'libcrystfel/src/crystal.c')
-rw-r--r-- | libcrystfel/src/crystal.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c index e6ae4b09..0cf246ae 100644 --- a/libcrystfel/src/crystal.c +++ b/libcrystfel/src/crystal.c @@ -41,6 +41,7 @@ struct _crystal { UnitCell *cell; + int owns_cell; double m; /* Mosaicity in radians */ double osf; double Bfac; @@ -72,6 +73,7 @@ Crystal *crystal_new() if ( cryst == NULL ) return NULL; cryst->cell = NULL; + cryst->owns_cell = 1; cryst->m = 0.0; cryst->osf = 1.0; cryst->Bfac = 0.0; @@ -128,6 +130,7 @@ Crystal *crystal_copy(const Crystal *cryst) void crystal_free(Crystal *cryst) { if ( cryst == NULL ) return; + if ( cryst->owns_cell ) cell_free(cryst->cell); cffree(cryst->notes); cffree(cryst); } @@ -142,6 +145,13 @@ UnitCell *crystal_get_cell(Crystal *cryst) } +UnitCell *crystal_relinquish_cell(Crystal *cryst) +{ + cryst->owns_cell = 0; + return cryst->cell; +} + + const UnitCell *crystal_get_cell_const(const Crystal *cryst) { return cryst->cell; @@ -217,6 +227,7 @@ void crystal_set_cell(Crystal *cryst, UnitCell *cell) { if ( cryst->owns_cell ) cell_free(cryst->cell); cryst->cell = cell; + cryst->owns_cell = 1; } |