Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Electrometers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Tango devices
MeasureInstruments
lib
Electrometers
Commits
b5a46ad5
Commit
b5a46ad5
authored
5 months ago
by
Jade PHAM
Browse files
Options
Downloads
Patches
Plain Diff
memory leak correction
parent
bca1fb15
No related branches found
No related tags found
1 merge request
!2
memory leak correction
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TangoEthernetLink.cpp
+18
-72
18 additions, 72 deletions
src/TangoEthernetLink.cpp
with
18 additions
and
72 deletions
src/TangoEthernetLink.cpp
+
18
−
72
View file @
b5a46ad5
...
...
@@ -55,17 +55,17 @@ void TangoEthernetLink::check_proxy (void) throw (Tango::DevFailed)
try
{
//- try
if
(
_ethernet_proxy
==
0
)
this
->
_ethernet_proxy
=
new
Tango
::
DeviceProxy
(
_communication_Device_name
.
c_str
());
_ethernet_proxy
->
ping
();
_is_ethernet_proxy_ok
=
true
;
}
catch
(
Tango
::
DevFailed
&
df
)
{
if
(
this
->
_ethernet_proxy
)
if
(
_ethernet_proxy
)
{
delete
this
->
_ethernet_proxy
;
this
->
_ethernet_proxy
=
0
;
delete
_ethernet_proxy
;
_ethernet_proxy
=
0
;
}
_is_ethernet_proxy_ok
=
false
;
description
=
"Unable to create proxy on : "
+
_communication_Device_name
;
...
...
@@ -77,10 +77,10 @@ void TangoEthernetLink::check_proxy (void) throw (Tango::DevFailed)
}
catch
(...)
{
if
(
this
->
_ethernet_proxy
)
if
(
_ethernet_proxy
)
{
delete
this
->
_ethernet_proxy
;
this
->
_ethernet_proxy
=
0
;
delete
_ethernet_proxy
;
_ethernet_proxy
=
0
;
}
_is_ethernet_proxy_ok
=
false
;
description
=
"Unable to create proxy on : "
+
_communication_Device_name
+
"
\n
memory allocation failed."
;
...
...
@@ -105,33 +105,8 @@ void TangoEthernetLink::write (std::string command_to_send) throw (Tango::DevFa
Tango
::
DeviceData
dd_in
;
Tango
::
DevString
argin
=
0
;
try
{
argin
=
new
char
[
command_to_send
.
size
()
+
1
];
strcpy
(
argin
,
command_to_send
.
c_str
());
}
catch
(
Tango
::
DevFailed
&
df
)
{
if
(
argin
)
{
delete
[]
argin
;
argin
=
0
;
}
description
=
"Unable to write command : "
+
command_to_send
+
+
"
\n
memory allocation failed."
;
Tango
::
Except
::
re_throw_exception
(
df
,
(
const
char
*
)
"ALLOCATION_ERROR"
,
description
.
c_str
(),
(
const
char
*
)
"TangoEthernetLink::write"
);
}
catch
(...)
{
description
=
"Unable to write command : "
+
command_to_send
+
"
\n
memory allocation failed."
;
Tango
::
Except
::
throw_exception
(
(
const
char
*
)
"ALLOCATION_ERROR"
,
description
.
c_str
(),
(
const
char
*
)
"TangoEthernetLink::write"
);
}
try
{
//- try
...
...
@@ -171,6 +146,10 @@ void TangoEthernetLink::write (std::string command_to_send) throw (Tango::DevFa
description
.
c_str
(),
(
const
char
*
)
"TangoEthernetLink::write"
);
}
if
(
argin
)
{
delete
[]
argin
;
}
}
...
...
@@ -189,7 +168,6 @@ std::string TangoEthernetLink::read (void) throw (Tango::DevFailed)
try
{
dd_out
=
_ethernet_proxy
->
command_inout
(
"Read"
);
dd_out
>>
response
;
}
...
...
@@ -217,42 +195,10 @@ std::string TangoEthernetLink::read (void) throw (Tango::DevFailed)
std
::
string
TangoEthernetLink
::
write_read
(
std
::
string
command_to_send
,
size_t
nbChar
)
throw
(
Tango
::
DevFailed
)
{
std
::
string
resp
;
check_proxy
();
if
(
!
_is_ethernet_proxy_ok
)
return
""
;
Tango
::
DeviceData
dd_in
;
Tango
::
DevString
argin
=
0
;
Tango
::
DeviceData
dd_out
;
std
::
string
response
(
""
);
try
{
argin
=
new
char
[
command_to_send
.
size
()
+
1
];
strcpy
(
argin
,
command_to_send
.
c_str
());
dd_in
<<
argin
;
dd_out
=
_ethernet_proxy
->
command_inout
(
"WriteRead"
,
dd_in
);
dd_out
>>
response
;
}
catch
(
Tango
::
DevFailed
&
df
)
{
Tango
::
Except
::
re_throw_exception
(
df
,
(
const
char
*
)
"COMMUNICATION_ERROR"
,
(
const
char
*
)
"Unable to perform a read operation"
,
(
const
char
*
)
"TangoEthernetLink::read"
);
}
catch
(...)
{
Tango
::
Except
::
throw_exception
(
(
const
char
*
)
"COMMUNICATION_ERROR"
,
(
const
char
*
)
"Unable to perform a read operation"
,
(
const
char
*
)
"TangoEthernetLink::read"
);
}
return
response
;
write
(
command_to_send
);
//- sleep a little bit to let the adapter(RS232/485) to switch mode
omni_thread
::
sleep
(
0
,
100000000
);
//100 milliseconds
return
read
();
}
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