+/**
+ * @brief Update atoms->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_atoms_residue_pointers_update
+ (const tng_trajectory_t tng_data,
+ const tng_molecule_t mol)
+{
+ tng_atom_t atom;
+ tng_residue_t residue;
+ int64_t i, j, atom_offset = 0;
+ (void)tng_data;
+
+ for(i = 0; i < mol->n_residues; i++)
+ {
+ residue = &mol->residues[i];
+ for(j = 0; j < residue->n_atoms; j++)
+ {
+ atom = &mol->atoms[j + atom_offset];
+ atom->residue = residue;
+ }
+ atom_offset += residue->n_atoms;
+ }
+ return(TNG_SUCCESS);
+}
+