diff --git a/src/space.c b/src/space.c index 490893326597cd5e3c95a4089a894d072f7d8cc6..5ef0ee1df094f70433d9b963c958338b334ac439 100644 --- a/src/space.c +++ b/src/space.c @@ -1481,8 +1481,8 @@ void space_split_recursive(struct space *s, struct cell *c, const int allocate_buffer = (buff == NULL && gbuff == NULL); if (allocate_buffer) { if (count > 0) { - if ((buff = (struct cell_buff *)malloc(sizeof(struct cell_buff) * - count)) == NULL) + if (posix_memalign((void *)&buff, SWIFT_STRUCT_ALIGNMENT, + sizeof(struct cell_buff) * count) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < count; k++) { buff[k].x[0] = parts[k].x[0]; @@ -1491,8 +1491,8 @@ void space_split_recursive(struct space *s, struct cell *c, } } if (gcount > 0) { - if ((gbuff = (struct cell_buff *)malloc(sizeof(struct cell_buff) * - gcount)) == NULL) + if (posix_memalign((void *)&gbuff, SWIFT_STRUCT_ALIGNMENT, + sizeof(struct cell_buff) * gcount) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < gcount; k++) { gbuff[k].x[0] = gparts[k].x[0];