Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IF Toolset
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2037-04-19.
Why is this scheduled?
Show more breadcrumbs
verimag
IF
IF Toolset
Commits
581111a2
Commit
581111a2
authored
3 years ago
by
Marius Bozga
Browse files
Options
Downloads
Patches
Plain Diff
fix memory leaks for labels in observers
parent
923b1300
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/simulator/observer.C
+16
-18
16 additions, 18 deletions
src/simulator/observer.C
src/simulator/observer.h
+4
-0
4 additions, 0 deletions
src/simulator/observer.h
with
20 additions
and
18 deletions
src/simulator/observer.C
+
16
−
18
View file @
581111a2
...
...
@@ -60,10 +60,16 @@ IfObserverInstance::IfObserverInstance(const IfObserverInstance& instance)
void
IfObserverInstance
::
copy
(
const
IfInstance
*
inst
)
{
IfObserverInstance
*
obs
=
(
IfObserverInstance
*
)
inst
;
m_curLabel
=
obs
->
m_curLabel
;
m_bCut
=
obs
->
m_bCut
;
}
void
IfObserverInstance
::
clearEventAt
(
const
int
i
)
{
// m_curLabel = m_curLabel->copy();
// m_curLabel->setAt(i, IfEvent::NIL);
IfLabel
l
(
*
m_curLabel
);
l
.
setAt
(
i
,
IfEvent
::
NIL
);
m_curLabel
=
l
.
store
();
}
unsigned
IfObserverInstance
::
if_pid_obs_queue_length
(
const
if_pid_type
pid
)
const
{
...
...
@@ -83,7 +89,7 @@ int IfObserverInstance::trace(const IfEvent* event) {
l
->
setAt
(
len
,
event
);
l
->
setAt
(
len
+
1
,
NULL
);
m_curLabel
=
l
->
store
();
delete
l
;
return
1
;
}
...
...
@@ -187,8 +193,7 @@ IfMessage* IfObserverInstance::if_obs_input_ext(unsigned sid, if_pid_type* pid)
if
(
evt
->
getKind
()
==
IfEvent
::
INPUT
&&
(
sid
==
(
unsigned
)
-
1
||
((
IfMessage
*
)
evt
->
getAuxObj
())
->
getSid
()
==
sid
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
pid
!=
NULL
)
*
pid
=
evt
->
getAuxPid
();
return
(
IfMessage
*
)
evt
->
getAuxObj
();
}
...
...
@@ -217,8 +222,7 @@ IfMessage* IfObserverInstance::if_obs_discard_ext(unsigned sid, if_pid_type* pid
if
(
evt
->
getKind
()
==
IfEvent
::
DISCARD
&&
(
sid
==
(
unsigned
)
-
1
||
((
IfMessage
*
)
evt
->
getAuxObj
())
->
getSid
()
==
sid
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
pid
!=
NULL
)
*
pid
=
evt
->
getAuxPid
();
return
(
IfMessage
*
)
evt
->
getAuxObj
();
}
...
...
@@ -251,8 +255,7 @@ IfMessage* IfObserverInstance::if_obs_output_ext(unsigned sid, unsigned index,
if
(
evt
->
getKind
()
==
IfEvent
::
OUTPUT
&&
(
sid
==
(
unsigned
)
-
1
||
((
IfMessage
*
)
evt
->
getAuxObj
())
->
getSid
()
==
sid
)
&&
!
(
index
--
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
from
!=
NULL
)
*
from
=
evt
->
getPid
();
if
(
via
!=
NULL
)
*
via
=
evt
->
getAuxPid
();
if
(
to
!=
NULL
)
{
...
...
@@ -287,8 +290,7 @@ void IfObserverInstance::if_obs_fork_ext(unsigned process, if_pid_type* var, if_
if
(
evt
->
getKind
()
==
IfEvent
::
FORK
&&
(
process
==
(
unsigned
)
-
1
||
process
==
if_pid_proc
(
evt
->
getAuxPid
())
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
var
!=
NULL
)
*
var
=
evt
->
getAuxPid
();
if
(
in
!=
NULL
)
*
in
=
evt
->
getPid
();
return
;
...
...
@@ -321,8 +323,7 @@ void IfObserverInstance::if_obs_kill_ext(unsigned process, if_pid_type* var, if_
if
(
evt
->
getKind
()
==
IfEvent
::
KILL
&&
(
process
==
(
unsigned
)
-
1
||
if_pid_proc
(
evt
->
getAuxPid
()
)
==
process
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
var
!=
NULL
)
*
var
=
evt
->
getAuxPid
();
if
(
in
!=
NULL
)
*
in
=
evt
->
getPid
();
return
;
...
...
@@ -353,8 +354,7 @@ IfMessage* IfObserverInstance::if_obs_deliver_ext(unsigned sid, if_pid_type* fro
if
(
evt
->
getKind
()
==
IfEvent
::
DELIVER
&&
(
sid
==
(
unsigned
)
-
1
||
((
IfMessage
*
)
evt
->
getAuxObj
())
->
getSid
()
==
sid
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
from
!=
NULL
)
*
from
=
evt
->
getPid
();
return
(
IfMessage
*
)
evt
->
getAuxObj
();
}
...
...
@@ -383,8 +383,7 @@ void IfObserverInstance::if_obs_informal_ext(char* name, if_pid_type* in)
if
(
evt
->
getKind
()
==
IfEvent
::
INFORMAL
&&
(
name
==
NULL
||
!
strcmp
(
name
,(
char
*
)
evt
->
getAuxObj
())
)
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
if
(
in
!=
NULL
)
*
in
=
evt
->
getPid
();
return
;
}
...
...
@@ -409,8 +408,7 @@ if_real_type IfObserverInstance::if_obs_probability_ext()
IfEvent
*
evt
=
m_curLabel
->
getAt
(
i
);
if
(
evt
->
getKind
()
==
IfEvent
::
PROBABILITY
)
{
m_curLabel
=
m_curLabel
->
copy
();
m_curLabel
->
setAt
(
i
,
IfEvent
::
NIL
);
clearEventAt
(
i
);
return
evt
->
getAuxProbability
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/simulator/observer.h
+
4
−
0
View file @
581111a2
...
...
@@ -64,10 +64,12 @@ class IfObserverInstance : public IfInstance {
DECLARE_STORABLE
(
IfInstance
)
protected
:
void
clearEventAt
(
const
int
);
unsigned
if_pid_obs_queue_length
(
const
if_pid_type
pid
)
const
;
protected
:
IfLabel
*
m_curLabel
;
public
:
int
trace
(
const
IfEvent
*
event
);
void
flushLabel
();
...
...
@@ -97,6 +99,8 @@ class IfObserverInstance : public IfInstance {
if_boolean_type
if_obs_probability
();
if_real_type
if_obs_probability_ext
();
public
:
long
unsigned
m_bCut
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment