Commit ebf2c31f authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Only relink parts and gparts when we actually have parts and gparts

parent b0a9dbfa
...@@ -580,7 +580,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) { ...@@ -580,7 +580,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) {
} }
/* Re-link the gparts. */ /* Re-link the gparts. */
part_relink_gparts(parts, count, parts_offset); if (count > 0 && gcount > 0) part_relink_gparts(parts, count, parts_offset);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Verify that _all_ the parts have been assigned to a cell. */ /* Verify that _all_ the parts have been assigned to a cell. */
...@@ -675,7 +675,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) { ...@@ -675,7 +675,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) {
} }
/* Re-link the parts. */ /* Re-link the parts. */
part_relink_parts(gparts, gcount, parts - parts_offset); if (count > 0 && gcount > 0)
part_relink_parts(gparts, gcount, parts - parts_offset);
} }
/** /**
......
...@@ -2936,7 +2936,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) { ...@@ -2936,7 +2936,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
s->xparts = xparts_new; s->xparts = xparts_new;
/* Re-link the gparts. */ /* Re-link the gparts. */
part_relink_gparts(s->parts, s->nr_parts, 0); if (s->nr_parts > 0 && s->nr_gparts > 0)
part_relink_gparts(s->parts, s->nr_parts, 0);
/* Re-allocate the local gparts. */ /* Re-allocate the local gparts. */
if (e->verbose) if (e->verbose)
...@@ -2952,7 +2953,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) { ...@@ -2952,7 +2953,8 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
s->gparts = gparts_new; s->gparts = gparts_new;
/* Re-link the parts. */ /* Re-link the parts. */
part_relink_parts(s->gparts, s->nr_gparts, s->parts); if (s->nr_parts > 0 && s->nr_gparts > 0)
part_relink_parts(s->gparts, s->nr_gparts, s->parts);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
......
...@@ -565,7 +565,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -565,7 +565,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
space_parts_sort(s, ind, nr_parts, 0, s->nr_cells - 1, verbose); space_parts_sort(s, ind, nr_parts, 0, s->nr_cells - 1, verbose);
/* Re-link the gparts. */ /* Re-link the gparts. */
part_relink_gparts(s->parts, nr_parts, 0); if (nr_parts > 0 && nr_gparts > 0) part_relink_gparts(s->parts, nr_parts, 0);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Verify space_sort_struct. */ /* Verify space_sort_struct. */
...@@ -613,7 +613,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -613,7 +613,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
space_gparts_sort(s, gind, nr_gparts, 0, s->nr_cells - 1, verbose); space_gparts_sort(s, gind, nr_gparts, 0, s->nr_cells - 1, verbose);
/* Re-link the parts. */ /* Re-link the parts. */
part_relink_parts(s->gparts, nr_gparts, s->parts); if (nr_parts > 0 && nr_gparts > 0)
part_relink_parts(s->gparts, nr_gparts, s->parts);
/* We no longer need the indices as of here. */ /* We no longer need the indices as of here. */
free(gind); free(gind);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment