diff --git a/src/space.c b/src/space.c index 630c576ce500d3b27ff81a51c592f5a78b3b5d53..645dda18442fa89a6b80179d5444538b321a201f 100644 --- a/src/space.c +++ b/src/space.c @@ -1602,25 +1602,15 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) { */ void space_recycle(struct space *s, struct cell *c) { - /* Lock the space. */ - lock_lock(&s->lock); - /* Clear the cell. */ if (lock_destroy(&c->lock) != 0) error("Failed to destroy spinlock."); /* Clear this cell's sort arrays. */ if (c->sort != NULL) free(c->sort); - /* Clear the cell data. */ - bzero(c, sizeof(struct cell)); - /* Hook this cell into the buffer. */ - c->next = s->cells_sub; - s->cells_sub = c; - s->tot_cells -= 1; - - /* Unlock the space. */ - lock_unlock_blind(&s->lock); + c->next = atomic_swap(&s->cells_sub, c); + atomic_dec(&s->tot_cells); } /**