*block_p = malloc(sizeof(struct tng_gen_block));
if(!*block_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_gen_block), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
if(molecule->n_residues > 0)
{
molecule->residues = malloc(molecule->n_residues *
- sizeof(struct tng_residue));
+ sizeof(struct tng_residue));
if(!molecule->residues)
{
fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIu64" bytes). %s: %d\n",
frame_set->n_particle_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_data) *
frame_set->n_particle_data_blocks,
__FILE__, __LINE__);
tng_data->n_particle_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_data) *
tng_data->n_particle_data_blocks,
__FILE__, __LINE__);
frame_set->n_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_data) * frame_set->n_data_blocks,
__FILE__, __LINE__);
free(frame_set->tr_data);
tng_data->n_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_data) * tng_data->n_data_blocks,
__FILE__, __LINE__);
free(tng_data->non_tr_data);
temp_name = realloc(block->name, len);
if(!temp_name)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n", len+1,
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n", len+1,
__FILE__, __LINE__);
free(block->name);
block->name = 0;
// }
*/
-tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data,
- const tng_atom_t atom,
- tng_residue_t *residue)
+tng_function_status DECLSPECDLLEXPORT tng_atom_residue_get
+ (const tng_trajectory_t tng_data,
+ const tng_atom_t atom,
+ tng_residue_t *residue)
{
(void) tng_data;
return(TNG_SUCCESS);
}
-tng_function_status tng_atom_name_get(const tng_trajectory_t tng_data,
- const tng_atom_t atom,
- char *name,
- const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_atom_name_get
+ (const tng_trajectory_t tng_data,
+ const tng_atom_t atom,
+ char *name,
+ const int max_len)
{
(void) tng_data;
TNG_ASSERT(atom, "TNG library: atom must not be NULL");
return(TNG_SUCCESS);
}
-tng_function_status tng_atom_name_set(const tng_trajectory_t tng_data,
- const tng_atom_t atom,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_atom_name_set
+ (const tng_trajectory_t tng_data,
+ const tng_atom_t atom,
+ const char *new_name)
{
unsigned int len;
(void)tng_data;
return(TNG_SUCCESS);
}
-tng_function_status tng_atom_type_get(const tng_trajectory_t tng_data,
- const tng_atom_t atom,
- char *type,
- const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_atom_type_get
+ (const tng_trajectory_t tng_data,
+ const tng_atom_t atom,
+ char *type,
+ const int max_len)
{
(void) tng_data;
TNG_ASSERT(atom, "TNG library: atom must not be NULL");
return(TNG_SUCCESS);
}
-tng_function_status tng_atom_type_set(const tng_trajectory_t tng_data,
- const tng_atom_t atom,
- const char *new_type)
+tng_function_status DECLSPECDLLEXPORT tng_atom_type_set
+ (const tng_trajectory_t tng_data,
+ const tng_atom_t atom,
+ const char *new_type)
{
unsigned int len;
(void)tng_data;
return(TNG_SUCCESS);
}
+/**
+ * @brief Update chain->residue pointers (after new memory for
+ * molecule->residues has been allocated).
+ * @param tng_data The trajectory container containing the molecule.
+ * @param mol The molecule that contains the chains that need to be
+ * updated.
+ * @returns TNG_SUCCESS (0) if successful.
+ */
+static tng_function_status tng_molecule_chains_residue_pointers_update
+ (const tng_trajectory_t tng_data,
+ const tng_molecule_t mol)
+{
+ tng_chain_t chain;
+ int64_t i, res_cnt = 0;
+ (void)tng_data;
+
+ for(i = 0; i < mol->n_chains; i++)
+ {
+ chain = &mol->chains[i];
+ chain->residues = mol->residues + res_cnt;
+ res_cnt += chain->n_residues;
+ }
+ return(TNG_SUCCESS);
+}
+
tng_function_status DECLSPECDLLEXPORT tng_version_major
(const tng_trajectory_t tng_data,
int *version)
*residue = &molecule->residues[curr_index + chain->n_residues];
- if(!chain->n_residues)
- {
- chain->residues = *residue;
- }
- else
- {
- chain->residues = &molecule->residues[curr_index];
- }
+ tng_molecule_chains_residue_pointers_update(tng_data, molecule);
(*residue)->name = 0;
tng_residue_name_set(tng_data, *residue, name);
*molecule_p = malloc(sizeof(struct tng_molecule));
if(!*molecule_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_molecule), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
*tng_data_p = malloc(sizeof(struct tng_trajectory));
if(!*tng_data_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_trajectory), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
*dest_p = malloc(sizeof(struct tng_trajectory));
if(!*dest_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"PRIuPTR" bytes). %s: %d\n",
sizeof(struct tng_trajectory), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
tng_function_status stat;
int64_t diff, n_mod, n_impl;
- TNG_ASSERT(n >= 0, "TNG library: The number of molecules must be >= 0");
+ TNG_ASSERT(n >= 0, "TNG library: The requested number of particles must be >= 0");
diff = n - tng_data->n_particles;