summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2013-11-28 10:28:51 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2013-11-28 10:28:51 (GMT)
commitefa81139369836056f2409f8422e6a87747058c4 (patch)
tree5ab20279470f45332e148363890a3369b4784fd3
parente9630831bca70be4c58727a4b97ea2453bdab193 (diff)
Fixing bug when copying molecules.
-rw-r--r--src/lib/tng_io.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index 2a8979e..fc7c574 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -7337,15 +7337,14 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(tng_trajectory_t
tng_data_dest->n_molecules = tng_data_src->n_molecules;
- molecule_temp = realloc(tng_data_dest->molecules,
- sizeof(struct tng_molecule) * tng_data_dest->n_molecules);
- if(!molecule_temp)
+ free(tng_data_dest->molecules);
+
+ tng_data_dest->molecules = malloc(sizeof(struct tng_molecule) * tng_data_dest->n_molecules);
+ if(!tng_data_dest->molecules)
{
printf("TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
sizeof(struct tng_molecule) * tng_data_dest->n_molecules,
__FILE__, __LINE__);
- free(tng_data_dest->molecules);
- tng_data_dest->molecules = 0;
return(TNG_CRITICAL);
}
list_temp = realloc(tng_data_dest->molecule_cnt_list,
contact: Jan Huwald // Impressum