diff --git a/src/space.c b/src/space.c
index 4a01b3b7a7ed80efa52ede5e7d20e5d595e49fa5..93af4222b7f56ae65e1d11d8c6df6026e180ff03 100644
--- a/src/space.c
+++ b/src/space.c
@@ -489,7 +489,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
     int *ind_new;
     if ((ind_new = (int *)malloc(sizeof(int) * s->nr_parts)) == NULL)
       error("Failed to allocate temporary particle indices.");
-    memcpy(ind_new, ind, sizeof(size_t) * nr_parts);
+    memcpy(ind_new, ind, sizeof(int) * nr_parts);
     free(ind);
     ind = ind_new;
   }