summaryrefslogtreecommitdiff
path: root/src/lib/tng_io.c
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2014-09-24 10:02:15 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2014-09-24 10:02:15 (GMT)
commit90de14812a5898cfe2241429f6a1313957b75417 (patch)
tree2d5ccbe59f7ec76b75ba9014e5ad96c89970e825 /src/lib/tng_io.c
parentba787e5b528ecdf8ba1d073144fd995a7ea3606d (diff)
Added new test (copy trajectory container and molsys)
Also fixed bugs in tng_trajectory_init_from_src. Change-Id: Iaa44e79f388b7add79973165801ab3dba57b3dcf
Diffstat (limited to 'src/lib/tng_io.c')
-rw-r--r--src/lib/tng_io.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index 947df1d..ff8dd40 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -9219,24 +9219,38 @@ tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajector
frame_set = &dest->current_trajectory_frame_set;
- dest->input_file_path = malloc(strlen(src->input_file_path) + 1);
- if(!dest->input_file_path)
+ if(src->input_file_path)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
- (unsigned int)strlen(src->input_file_path) + 1, __FILE__, __LINE__);
- return(TNG_CRITICAL);
+ dest->input_file_path = malloc(strlen(src->input_file_path) + 1);
+ if(!dest->input_file_path)
+ {
+ fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
+ (unsigned int)strlen(src->input_file_path) + 1, __FILE__, __LINE__);
+ return(TNG_CRITICAL);
+ }
+ strcpy(dest->input_file_path, src->input_file_path);
+ dest->input_file_len = src->input_file_len;
+ }
+ else
+ {
+ dest->input_file_path = 0;
}
- strcpy(dest->input_file_path, src->input_file_path);
dest->input_file = 0;
- dest->input_file_len = src->input_file_len;
- dest->output_file_path = malloc(strlen(src->output_file_path) + 1);
- if(!dest->output_file_path)
+ if(src->output_file_path)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
- (unsigned int)strlen(src->output_file_path) + 1, __FILE__, __LINE__);
- return(TNG_CRITICAL);
+ dest->output_file_path = malloc(strlen(src->output_file_path) + 1);
+ if(!dest->output_file_path)
+ {
+ fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
+ (unsigned int)strlen(src->output_file_path) + 1, __FILE__, __LINE__);
+ return(TNG_CRITICAL);
+ }
+ strcpy(dest->output_file_path, src->output_file_path);
+ }
+ else
+ {
+ dest->output_file_path = 0;
}
- strcpy(dest->output_file_path, src->output_file_path);
dest->output_file = 0;
dest->first_program_name = 0;
@@ -9291,6 +9305,9 @@ tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajector
frame_set->tr_particle_data = 0;
frame_set->tr_data = 0;
+ frame_set->n_written_frames = 0;
+ frame_set->n_unwritten_frames = 0;
+
frame_set->next_frame_set_file_pos = -1;
frame_set->prev_frame_set_file_pos = -1;
frame_set->medium_stride_next_frame_set_file_pos = -1;
contact: Jan Huwald // Impressum