Skip to content
Browse files

remove remaining NULL pointers by nullptrs

  • Loading branch information...
1 parent 0c59ecf commit de7c56c6bc5388bd706a42af285544099617f81c @DennisOSRM DennisOSRM committed Jun 24, 2014
Showing with 35 additions and 44 deletions.
  1. +5 −14 Algorithms/StronglyConnectedComponents.h
  2. +3 −3 Contractor/Contractor.h
  3. +6 −6 DataStructures/InputReaderFactory.h
  4. +21 −21 Extractor/XMLParser.cpp
View
19 Algorithms/StronglyConnectedComponents.h
@@ -214,20 +214,20 @@ class TarjanSCC
const char *pszDriverName = "ESRI Shapefile";
OGRSFDriver *poDriver =
OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszDriverName);
- if (NULL == poDriver)
+ if (nullptr == poDriver)
{
throw OSRMException("ESRI Shapefile driver not available");
}
- OGRDataSource *poDS = poDriver->CreateDataSource("component.shp", NULL);
+ OGRDataSource *poDS = poDriver->CreateDataSource("component.shp", nullptr);
- if (NULL == poDS)
+ if (nullptr == poDS)
{
throw OSRMException("Creation of output file failed");
}
- OGRLayer *poLayer = poDS->CreateLayer("component", NULL, wkbLineString, NULL);
+ OGRLayer *poLayer = poDS->CreateLayer("component", nullptr, wkbLineString, nullptr);
- if (NULL == poLayer)
+ if (nullptr == poLayer)
{
throw OSRMException("Layer creation failed.");
}
@@ -325,15 +325,6 @@ class TarjanSCC
SimpleLogger().Write() << "identified: " << component_size_vector.size()
<< " many components, marking small components";
- // TODO/C++11: prime candidate for lambda function
- // unsigned size_one_counter = 0;
- // for (unsigned i = 0, end = component_size_vector.size(); i < end; ++i)
- // {
- // if (1 == component_size_vector[i])
- // {
- // ++size_one_counter;
- // }
- // }
unsigned size_one_counter = std::count_if(component_size_vector.begin(),
component_size_vector.end(),
[] (unsigned value) { return 1 == value;});
View
6 Contractor/Contractor.h
@@ -731,7 +731,7 @@ class Contractor
template <bool RUNSIMULATION>
inline bool
- ContractNode(ContractorThreadData *data, NodeID node, ContractionStats *stats = NULL)
+ ContractNode(ContractorThreadData *data, NodeID node, ContractionStats *stats = nullptr)
{
ContractorHeap &heap = data->heap;
int inserted_edges_size = data->inserted_edges.size();
@@ -743,7 +743,7 @@ class Contractor
const NodeID source = contractor_graph->GetTarget(in_edge);
if (RUNSIMULATION)
{
- BOOST_ASSERT(stats != NULL);
+ BOOST_ASSERT(stats != nullptr);
++stats->edges_deleted_count;
stats->original_edges_deleted_count += in_data.originalEdges;
}
@@ -796,7 +796,7 @@ class Contractor
{
if (RUNSIMULATION)
{
- BOOST_ASSERT(stats != NULL);
+ BOOST_ASSERT(stats != nullptr);
stats->edges_added_count += 2;
stats->original_edges_added_count +=
2 * (out_data.originalEdges + in_data.originalEdges);
View
12 DataStructures/InputReaderFactory.h
@@ -44,8 +44,8 @@ struct BZ2Context
int readFromBz2Stream(void *pointer, char *buffer, int len)
{
- void *unusedTmpVoid = NULL;
- char *unusedTmp = NULL;
+ void *unusedTmpVoid = nullptr;
+ char *unusedTmp = nullptr;
BZ2Context *context = (BZ2Context *)pointer;
int read = 0;
while (0 == read &&
@@ -76,7 +76,7 @@ int readFromBz2Stream(void *pointer, char *buffer, int len)
{
context->bz2 = BZ2_bzReadOpen(
&context->error, context->file, 0, 0, context->unused, context->nUnused);
- BOOST_ASSERT_MSG(NULL != context->bz2, "Could not open file");
+ BOOST_ASSERT_MSG(nullptr != context->bz2, "Could not open file");
}
}
else
@@ -107,12 +107,12 @@ xmlTextReaderPtr inputReaderFactory(const char *name)
int error;
context->bz2 =
BZ2_bzReadOpen(&error, context->file, 0, 0, context->unused, context->nUnused);
- if (context->bz2 == NULL || context->file == NULL)
+ if (context->bz2 == nullptr || context->file == nullptr)
{
delete context;
- return NULL;
+ return nullptr;
}
- return xmlReaderForIO(readFromBz2Stream, closeBz2Stream, (void *)context, NULL, NULL, 0);
+ return xmlReaderForIO(readFromBz2Stream, closeBz2Stream, (void *)context, nullptr, nullptr, 0);
}
else
{
View
42 Extractor/XMLParser.cpp
@@ -62,7 +62,7 @@ bool XMLParser::Parse()
}
xmlChar *currentName = xmlTextReaderName(inputReader);
- if (currentName == NULL)
+ if (currentName == nullptr)
{
continue;
}
@@ -115,7 +115,7 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
}
const int child_depth = xmlTextReaderDepth(inputReader);
xmlChar *child_name = xmlTextReaderName(inputReader);
- if (child_name == NULL)
+ if (child_name == nullptr)
{
continue;
}
@@ -135,7 +135,7 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
{
xmlChar *key = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"k");
xmlChar *value = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"v");
- if (key != NULL && value != NULL)
+ if (key != nullptr && value != nullptr)
{
if (xmlStrEqual(key, (const xmlChar *)"restriction") &&
StringStartsWith((const char *)value, "only_"))
@@ -148,19 +148,19 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
}
}
- if (key != NULL)
+ if (key != nullptr)
{
xmlFree(key);
}
- if (value != NULL)
+ if (value != nullptr)
{
xmlFree(value);
}
}
else if (xmlStrEqual(child_name, (const xmlChar *)"member") == 1)
{
xmlChar *ref = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"ref");
- if (ref != NULL)
+ if (ref != nullptr)
{
xmlChar *role = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"role");
xmlChar *type = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"type");
@@ -181,15 +181,15 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
restriction.restriction.viaNode = StringToUint((const char *)ref);
}
- if (NULL != type)
+ if (nullptr != type)
{
xmlFree(type);
}
- if (NULL != role)
+ if (nullptr != role)
{
xmlFree(role);
}
- if (NULL != ref)
+ if (nullptr != ref)
{
xmlFree(ref);
}
@@ -222,7 +222,7 @@ ExtractionWay XMLParser::ReadXMLWay()
}
const int child_depth = xmlTextReaderDepth(inputReader);
xmlChar *child_name = xmlTextReaderName(inputReader);
- if (child_name == NULL)
+ if (child_name == nullptr)
{
continue;
}
@@ -247,23 +247,23 @@ ExtractionWay XMLParser::ReadXMLWay()
xmlChar *key = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"k");
xmlChar *value = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"v");
- if (key != NULL && value != NULL)
+ if (key != nullptr && value != nullptr)
{
way.keyVals.Add(std::string((char *)key), std::string((char *)value));
}
- if (key != NULL)
+ if (key != nullptr)
{
xmlFree(key);
}
- if (value != NULL)
+ if (value != nullptr)
{
xmlFree(value);
}
}
else if (xmlStrEqual(child_name, (const xmlChar *)"nd") == 1)
{
xmlChar *ref = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"ref");
- if (ref != NULL)
+ if (ref != nullptr)
{
way.path.push_back(StringToUint((const char *)ref));
xmlFree(ref);
@@ -279,19 +279,19 @@ ImportNode XMLParser::ReadXMLNode()
ImportNode node;
xmlChar *attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"lat");
- if (attribute != NULL)
+ if (attribute != nullptr)
{
node.lat = static_cast<int>(COORDINATE_PRECISION * StringToDouble((const char *)attribute));
xmlFree(attribute);
}
attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"lon");
- if (attribute != NULL)
+ if (attribute != nullptr)
{
node.lon = static_cast<int>(COORDINATE_PRECISION * StringToDouble((const char *)attribute));
xmlFree(attribute);
}
attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"id");
- if (attribute != NULL)
+ if (attribute != nullptr)
{
node.node_id = StringToUint((const char *)attribute);
xmlFree(attribute);
@@ -312,7 +312,7 @@ ImportNode XMLParser::ReadXMLNode()
}
const int child_depth = xmlTextReaderDepth(inputReader);
xmlChar *child_name = xmlTextReaderName(inputReader);
- if (child_name == NULL)
+ if (child_name == nullptr)
{
continue;
}
@@ -333,15 +333,15 @@ ImportNode XMLParser::ReadXMLNode()
{
xmlChar *key = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"k");
xmlChar *value = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"v");
- if (key != NULL && value != NULL)
+ if (key != nullptr && value != nullptr)
{
node.keyVals.Add(std::string((char *)(key)), std::string((char *)(value)));
}
- if (key != NULL)
+ if (key != nullptr)
{
xmlFree(key);
}
- if (value != NULL)
+ if (value != nullptr)
{
xmlFree(value);
}

0 comments on commit de7c56c

Please sign in to comment.
Something went wrong with that request. Please try again.