diff --git a/src/space.c b/src/space.c index e9cfe1cf4ea0e50aadd0f3d3e3ddf195728f43fc..935677a9ebed97acfde8341ec1545ef4f33a56c0 100644 --- a/src/space.c +++ b/src/space.c @@ -454,7 +454,9 @@ void space_rebuild(struct space *s, int verbose) { struct cell *restrict cells_top = s->cells_top; const int ti_current = (s->e != NULL) ? s->e->ti_current : 0; - /* Run through the particles and get their cell index. */ + /* Run through the particles and get their cell index. Allocates + an index that is larger than the number of particles to avoid + re-allocating after shuffling. */ const size_t ind_size = s->size_parts + 100; int *ind; if ((ind = (int *)malloc(sizeof(int) * ind_size)) == NULL)