From db7d4314ae061bab90e5e8ab7bf10c769e535dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 28 Feb 2019 17:20:29 +0000 Subject: [PATCH] ss constructor: otspace realloc Former-commit-id: 0c534b05f4bb85ec7226251e3e350d69744ec359 --- qpms/scatsystem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index bf3db89..3056b6f 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -460,6 +460,17 @@ qpms_scatsys_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const qp ss->p_orbitinfo = realloc(ss->p_orbitinfo, sizeof(qpms_ss_particle_orbitinfo_t)*ss->p_count); ss->p_capacity = ss->p_count; + { // Reallocate the orbit type data space and update the pointers if needed. + size_t otspace_sz = ss->otspace_end - ss->otspace; + char *old_otspace = ss->otspace; + ss->otspace = realloc(ss->otspace, otspace_sz); + ptrdiff_t shift = ss->otspace - old_otspace; + if(shift) + for (size_t oi = 0; oi < ss->orbit_type_count; ++oi) { + (char *) (ss->orbit_types[i].action) += shift; + (char *) (ss->orbit_types[i].tmatrices) += shift; + } + } // Set ss->fecv_size and ss->fecv_pstarts ss->fecv_size = 0;