Commit 6f1e8f1b authored by Nils Kaminski's avatar Nils Kaminski
Browse files

Fix potential memory leak in c code

parent 5833fdab
......@@ -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"));
......
......@@ -2,8 +2,8 @@ package instanceRequest;
dynamic component TestBig{
port
dynamic in B a[0:1024],
dynamic out B b[0:1024];
dynamic in B a[0:128],
dynamic out B b[0:128];
component PassThrough {
ports
......@@ -13,7 +13,7 @@ dynamic component TestBig{
connect in1 -> out1;
}
instance PassThrough pt[0:1024];
instance PassThrough pt[0:128];
@ a::connect && b::connect {
connect a[?] -> pt[?].in1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment