diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/tng_io.c | 16 | 
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 72e0c08..051c9bc 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -17948,6 +17948,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat      tng_gen_block_t block;      int64_t i, j, block_id, *temp;      int64_t data_first_frame, frame_diff, min_diff; +    int64_t size, index;      int found, read_all = 0;      long file_pos; @@ -18066,8 +18067,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat              }              if(n_requested_data_block_ids <= 0)              { -                temp = realloc(*data_block_ids_in_next_frame, sizeof(int64_t) * -                               (*n_data_blocks_in_next_frame)); +                size = sizeof(int64_t) * (*n_data_blocks_in_next_frame); +                temp = realloc(*data_block_ids_in_next_frame, size);                  if(!temp)                  {                      printf("TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n", @@ -18083,8 +18084,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat              {                  TNG_ASSERT(*n_data_blocks_in_next_frame <= n_requested_data_block_ids, "TNG library: Array of data block IDs out of bounds");              } - -            *data_block_ids_in_next_frame[(*n_data_blocks_in_next_frame)-1] = block_id; +            index = (*n_data_blocks_in_next_frame) - 1; +            *data_block_ids_in_next_frame[index] = block_id;              min_diff = frame_diff;          } @@ -18144,8 +18145,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat              }              if(n_requested_data_block_ids <= 0)              { -                temp = realloc(*data_block_ids_in_next_frame, sizeof(int64_t) * -                               (*n_data_blocks_in_next_frame)); +                size = sizeof(int64_t) * (*n_data_blocks_in_next_frame); +                temp = realloc(*data_block_ids_in_next_frame, size);                  if(!temp)                  {                      printf("TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n", @@ -18161,7 +18162,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat              {                  TNG_ASSERT(*n_data_blocks_in_next_frame <= n_requested_data_block_ids, "TNG library: Array of data block IDs out of bounds");              } -            *data_block_ids_in_next_frame[(*n_data_blocks_in_next_frame)-1] = block_id; +            index = (*n_data_blocks_in_next_frame) - 1; +            *data_block_ids_in_next_frame[index] = block_id;              min_diff = frame_diff;          }  | 
