Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
6f1e8f1b
Commit
6f1e8f1b
authored
Nov 13, 2018
by
Nils Kaminski
Browse files
Fix potential memory leak in c code
parent
5833fdab
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/EventDynamicConnectConverter.java
View file @
6f1e8f1b
...
...
@@ -24,7 +24,7 @@ public class EventDynamicConnectConverter {
protected
static
final
String
DYNPORTIDININSTANCE
=
"_%s_%s_dynPortID"
;
protected
static
final
String
DYNPORTIDININSTANCEINIT
=
"int "
+
DYNPORTIDININSTANCE
+
" = -1;\n"
;
protected
static
final
String
DYNINSTANCEID
=
"_%s_dynINSTID"
;
protected
static
final
String
DYNINSTANCECONNECT
=
"int "
+
DYNINSTANCEID
+
" = dynamicconnect(%d, __%s_connected); if( "
+
DYNINSTANCEID
+
" < 0 ){return; } _connected_idxs[%d] = "
+
DYNINSTANCEID
+
";\n"
;
protected
static
final
String
DYNINSTANCECONNECT
=
"int "
+
DYNINSTANCEID
+
" = dynamicconnect(%d, __%s_connected); if( "
+
DYNINSTANCEID
+
" < 0 ){
free(_connected_idxs);
return; } _connected_idxs[%d] = "
+
DYNINSTANCEID
+
";\n"
;
protected
static
final
String
FREE_CONNECTIONTRACARRAY
=
"__event_connects_%s"
;
protected
static
final
String
FREE_THISCOMPONENTPORTREQUEST
=
"int "
+
DYNPORTID
+
" = _connected_idxs[%d];\n"
;
...
...
@@ -296,7 +296,7 @@ public class EventDynamicConnectConverter {
));
body
.
addInstruction
(
new
TargetCodeInstruction
(
String
.
format
(
"if(!"
+
inst
+
")){return ;}\n"
"if(!"
+
inst
+
")){
free(_connected_idxs);
return ;}\n"
)));
body
.
addInstruction
(
new
TargetCodeInstruction
(
connectIdxs
+
"\n"
));
...
...
src/test/resources/dynamics/instanceRequest/TestBig.emam
View file @
6f1e8f1b
...
...
@@ -2,8 +2,8 @@ package instanceRequest;
dynamic
component
TestBig
{
port
dynamic
in
B
a
[
0
:
1
024
],
dynamic
out
B
b
[
0
:
1
024
];
dynamic
in
B
a
[
0
:
1
28
],
dynamic
out
B
b
[
0
:
1
28
];
component
PassThrough
{
ports
...
...
@@ -13,7 +13,7 @@ dynamic component TestBig{
connect
in1
->
out1
;
}
instance
PassThrough
pt
[
0
:
1
024
];
instance
PassThrough
pt
[
0
:
1
28
];
@
a
::
connect
&&
b
::
connect
{
connect
a
[?]
->
pt
[?].
in1
;
...
...
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