Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
bb1a8c30
Commit
bb1a8c30
authored
Nov 15, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leak in message_data::copy
parent
a2862f39
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
libcaf_core/caf/typed_message_view.hpp
libcaf_core/caf/typed_message_view.hpp
+1
-1
libcaf_core/src/detail/message_data.cpp
libcaf_core/src/detail/message_data.cpp
+1
-0
libcaf_core/test/message.cpp
libcaf_core/test/message.cpp
+18
-0
No files found.
libcaf_core/caf/typed_message_view.hpp
View file @
bb1a8c30
...
...
@@ -32,7 +32,7 @@ public:
// nop
}
explicit
typed_message_view
(
message
&
msg
)
:
ptr_
(
&
msg
.
data
())
{
explicit
typed_message_view
(
message
&
msg
)
:
ptr_
(
msg
.
ptr
())
{
// nop
}
...
...
libcaf_core/src/detail/message_data.cpp
View file @
bb1a8c30
...
...
@@ -69,6 +69,7 @@ message_data* message_data::copy() const {
auto
&
meta
=
gmos
[
id
];
// TODO: exception handling.
meta
.
copy_construct
(
dst
,
src
);
++
ptr
->
constructed_elements_
;
src
+=
meta
.
padded_size
;
dst
+=
meta
.
padded_size
;
}
...
...
libcaf_core/test/message.cpp
View file @
bb1a8c30
...
...
@@ -61,6 +61,24 @@ CAF_TEST(messages allow index - based access) {
CAF_CHECK_EQUAL
(
msg
.
cdata
().
get_reference_count
(),
1u
);
}
CAF_TEST
(
message
detach
their
content
on
mutating
access
)
{
CAF_MESSAGE
(
"Given to messages pointing to the same content."
);
auto
msg1
=
make_message
(
"one"
,
uint32_t
{
1
});
auto
msg2
=
msg1
;
CAF_CHECK_EQUAL
(
msg1
.
cdata
().
get_reference_count
(),
2u
);
CAF_CHECK_EQUAL
(
msg1
.
cptr
(),
msg2
.
cptr
());
CAF_MESSAGE
(
"When calling a non-const member function of message."
);
msg1
.
ptr
();
CAF_MESSAGE
(
"Then the messages point to separate contents but remain equal."
);
CAF_CHECK_NOT_EQUAL
(
msg1
.
cptr
(),
msg2
.
cptr
());
CAF_CHECK_EQUAL
(
msg1
.
cdata
().
get_reference_count
(),
1u
);
CAF_CHECK_EQUAL
(
msg2
.
cdata
().
get_reference_count
(),
1u
);
CAF_CHECK
(
msg1
.
match_elements
<
std
::
string
,
uint32_t
>
());
CAF_CHECK
(
msg2
.
match_elements
<
std
::
string
,
uint32_t
>
());
CAF_CHECK_EQUAL
(
msg1
.
get_as
<
std
::
string
>
(
0
),
msg2
.
get_as
<
std
::
string
>
(
0
));
CAF_CHECK_EQUAL
(
msg1
.
get_as
<
uint32_t
>
(
1
),
msg2
.
get_as
<
uint32_t
>
(
1
));
}
CAF_TEST
(
compare_custom_types
)
{
s2
tmp
;
tmp
.
value
[
0
][
1
]
=
100
;
...
...
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