mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Fixed possible nullptr references
This commit is contained in:
parent
8659091ff3
commit
8441069b71
@ -290,16 +290,23 @@ namespace etl
|
||||
{
|
||||
// If critical node matches child node direction then perform a two
|
||||
// node rotate in the direction of the critical node
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
// Check for nullptr before dereferencing to avoid C28182 warning
|
||||
if (critical_node->children[critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
if (critical_node->children[critical_node->dir]->children[1 - critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,16 +286,22 @@ namespace etl
|
||||
{
|
||||
// If critical node matches child node direction then perform a two
|
||||
// node rotate in the direction of the critical node
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
if (critical_node->children[critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
if (critical_node->children[critical_node->dir]->children[1 - critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,16 +341,22 @@ namespace etl
|
||||
{
|
||||
// If critical node matches child node direction then perform a two
|
||||
// node rotate in the direction of the critical node
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
if (critical_node->children[critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
if (critical_node->children[critical_node->dir]->children[1 - critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,16 +325,22 @@ namespace etl
|
||||
{
|
||||
// If critical node matches child node direction then perform a two
|
||||
// node rotate in the direction of the critical node
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
if (critical_node->children[critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
if (critical_node->weight == critical_node->children[critical_node->dir]->dir)
|
||||
{
|
||||
rotate_2node(critical_node, critical_node->dir);
|
||||
}
|
||||
// Otherwise perform a three node rotation in the direction of the
|
||||
// critical node
|
||||
else
|
||||
{
|
||||
if (critical_node->children[critical_node->dir]->children[1 - critical_node->dir] != ETL_NULLPTR) ETL_UNLIKELY
|
||||
{
|
||||
rotate_3node(critical_node, critical_node->dir,
|
||||
critical_node->children[critical_node->dir]->children[1 - critical_node->dir]->dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user