Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
bad3fec3
Commit
bad3fec3
authored
Aug 28, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rc-stack memory leak in sequential
parent
1de8c287
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
src/util/rc-stack.c
src/util/rc-stack.c
+13
-7
tests/rc-stack-test.c
tests/rc-stack-test.c
+2
-0
No files found.
src/util/rc-stack.c
View file @
bad3fec3
...
...
@@ -18,6 +18,7 @@ typedef struct rc_entry_s {
struct
rc_stack
{
int
count
;
int
is_in_optimistic
;
struct
qlist_head
head
;
};
...
...
@@ -27,6 +28,7 @@ void rc_stack_create(struct rc_stack **s){
INIT_QLIST_HEAD
(
&
ss
->
head
);
ss
->
count
=
0
;
}
ss
->
is_in_optimistic
=
(
g_tw_synchronization_protocol
==
OPTIMISTIC
);
*
s
=
ss
;
}
...
...
@@ -40,13 +42,17 @@ void rc_stack_push(
void
*
data
,
void
(
*
free_fn
)(
void
*
),
struct
rc_stack
*
s
){
rc_entry
*
ent
=
(
rc_entry
*
)
malloc
(
sizeof
(
*
ent
));
assert
(
ent
);
ent
->
time
=
tw_now
(
lp
);
ent
->
data
=
data
;
ent
->
free_fn
=
free_fn
;
qlist_add_tail
(
&
ent
->
ql
,
&
s
->
head
);
s
->
count
++
;
if
(
s
->
is_in_optimistic
||
free_fn
==
NULL
)
{
rc_entry
*
ent
=
(
rc_entry
*
)
malloc
(
sizeof
(
*
ent
));
assert
(
ent
);
ent
->
time
=
tw_now
(
lp
);
ent
->
data
=
data
;
ent
->
free_fn
=
free_fn
;
qlist_add_tail
(
&
ent
->
ql
,
&
s
->
head
);
s
->
count
++
;
}
else
free_fn
(
data
);
}
void
*
rc_stack_pop
(
struct
rc_stack
*
s
){
...
...
tests/rc-stack-test.c
View file @
bad3fec3
...
...
@@ -21,6 +21,8 @@ int main(int argc, char *argv[])
lp
.
pe
=
&
pe
;
lp
.
kp
=
&
kp
;
g_tw_synchronization_protocol
=
OPTIMISTIC
;
struct
rc_stack
*
s
;
rc_stack_create
(
&
s
);
assert
(
s
!=
NULL
);
...
...
Write
Preview
Markdown
is supported
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