diff options
Diffstat (limited to 'src/sfac.c')
-rw-r--r-- | src/sfac.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -323,6 +323,7 @@ struct molecule *load_molecule() if ( mol == NULL ) return NULL; mol->n_species = 0; mol->reflections = NULL; + mol->cell = NULL; fh = fopen("molecule.pdb", "r"); if ( fh == NULL ) { @@ -443,6 +444,41 @@ struct molecule *load_molecule() } +void free_molecule(struct molecule *mol) +{ + int i; + + for ( i=0; i<mol->n_species; i++ ) { + free(mol->species[i]); + } + + free(mol->cell); + free(mol); +} + + +struct molecule *copy_molecule(struct molecule *orig) +{ + struct molecule *new; + int i; + + new = malloc(sizeof(*new)); + *new = *orig; + + /* Now sort out pointers */ + for ( i=0; i<orig->n_species; i++ ) { + new->species[i] = malloc(sizeof(struct mol_species)); + memcpy(new->species[i], orig->species[i], + sizeof(struct mol_species)); + } + + new->cell = cell_new_from_cell(orig->cell); + new->reflections = NULL; + + return new; +} + + double complex *get_reflections(struct molecule *mol, double en) { double complex *reflections; |