mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-17 02:03:15 +09:00
Take advantage of delete not acting on null values
The code 'delete 0' does nothing. So you can shorten code
like:
if (x != 0) {
delete x
}
to simply: delete x
(cherry picked from commit f7ecf6f8fc)
This commit is contained in:
1 parent
b38d808f3c
commit
453aeb7ca9
6 files changed
+13
-52
No files matched your search
@@ -47,10 +47,7 @@ Document::Document( int id,
|
||||
|
||||
Document::~Document()
|
||||
{
|
||||
if ( obj_template != 0 )
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
+1
-4
@@ -49,10 +49,7 @@ Host::Host(
|
||||
|
||||
Host::~Host()
|
||||
{
|
||||
if ( obj_template != 0 )
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
+1
-4
@@ -72,10 +72,7 @@ Image::Image(int _uid,
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
if (obj_template != 0)
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
@@ -83,23 +83,12 @@ VirtualMachine::~VirtualMachine()
|
||||
{
|
||||
for (unsigned int i=0 ; i < history_records.size() ; i++)
|
||||
{
|
||||
delete history_records[i];
|
||||
delete history_records[i];
|
||||
}
|
||||
|
||||
if (_log != 0)
|
||||
{
|
||||
delete _log;
|
||||
}
|
||||
|
||||
if (obj_template != 0)
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
if (user_obj_template != 0)
|
||||
{
|
||||
delete user_obj_template;
|
||||
}
|
||||
delete _log;
|
||||
delete obj_template;
|
||||
delete user_obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
@@ -788,10 +777,7 @@ int VirtualMachine::parse_context(string& error_str)
|
||||
|
||||
for (int i = 0; i < num ; i++)
|
||||
{
|
||||
if (array_context[i] != 0)
|
||||
{
|
||||
delete array_context[i];
|
||||
}
|
||||
delete array_context[i];
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -911,10 +897,7 @@ int VirtualMachine::parse_context(string& error_str)
|
||||
error_cleanup:
|
||||
for (int i = 0; i < num ; i++)
|
||||
{
|
||||
if (array_context[i] != 0)
|
||||
{
|
||||
delete array_context[i];
|
||||
}
|
||||
delete array_context[i];
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -1042,10 +1025,7 @@ int VirtualMachine::parse_requirements(string& error_str)
|
||||
error_cleanup:
|
||||
for (int i = 0; i < num ; i++)
|
||||
{
|
||||
if (array_reqs[i] != 0)
|
||||
{
|
||||
delete array_reqs[i];
|
||||
}
|
||||
delete array_reqs[i];
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -49,10 +49,7 @@ VMTemplate::VMTemplate(int id,
|
||||
|
||||
VMTemplate::~VMTemplate()
|
||||
{
|
||||
if ( obj_template != 0 )
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
@@ -68,15 +68,8 @@ VirtualNetwork::VirtualNetwork(int _uid,
|
||||
|
||||
VirtualNetwork::~VirtualNetwork()
|
||||
{
|
||||
if (leases != 0)
|
||||
{
|
||||
delete leases;
|
||||
}
|
||||
|
||||
if (obj_template != 0)
|
||||
{
|
||||
delete obj_template;
|
||||
}
|
||||
delete leases;
|
||||
delete obj_template;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
Reference in new issue
Block a user