Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
6979ad47
Commit
6979ad47
authored
Dec 12, 2016
by
Pedro Gonnet
Browse files
don't mess-up the list by clearing linked cells.
parent
981be8bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/space.c
View file @
6979ad47
...
...
@@ -434,9 +434,8 @@ void space_regrid(struct space *s, int verbose) {
// message( "rebuilding upper-level cells took %.3f %s." ,
// clocks_from_ticks(double)(getticks() - tic), clocks_getunit());
}
/* re-build upper-level cells? */
else
{
/* Otherwise, just clean up the cells. */
}
/* re-build upper-level cells? */
else
{
/* Otherwise, just clean up the cells. */
/* Free the old cells, if they were allocated. */
threadpool_map
(
&
s
->
e
->
threadpool
,
space_rebuild_recycle_mapper
,
...
...
@@ -1623,16 +1622,13 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) {
}
/**
* @brief Return a used cell to the buffer o
d
unused sub-cells.
* @brief Return a used cell to the buffer o
f
unused sub-cells.
*
* @param s The #space.
* @param c The #cell.
*/
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."
);
...
...
@@ -1642,6 +1638,9 @@ void space_recycle(struct space *s, struct cell *c) {
/* Clear the cell data. */
bzero
(
c
,
sizeof
(
struct
cell
));
/* Lock the space. */
lock_lock
(
&
s
->
lock
);
/* Hook this cell into the buffer. */
c
->
next
=
s
->
cells_sub
;
s
->
cells_sub
=
c
;
...
...
@@ -1651,6 +1650,16 @@ void space_recycle(struct space *s, struct cell *c) {
lock_unlock_blind
(
&
s
->
lock
);
}
/**
* @brief Return a list of used cells to the buffer of unused sub-cells.
*
* @param s The #space.
* @param list_begin Pointer to the first #cell in the linked list of
* cells joined by their @c next pointers.
* @param list_begin Pointer to the last #cell in the linked list of
* cells joined by their @c next pointers. It is assumed that this
* cell's @c next pointer is @c NULL.
*/
void
space_recycle_list
(
struct
space
*
s
,
struct
cell
*
list_begin
,
struct
cell
*
list_end
)
{
...
...
@@ -1662,10 +1671,10 @@ void space_recycle_list(struct space *s, struct cell *list_begin,
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
));
if
(
c
->
sort
!=
NULL
)
{
free
(
c
->
sort
);
c
->
sort
=
NULL
;
}
/* Count this cell. */
count
+=
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment