replacing unsafe strcpy operations
This commit is contained in:
parent
845c73af73
commit
2ccd3da5b3
@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
inline void ConstructGrid(DeallocatingVector<EdgeT> & edgeList, char * ramIndexOut, char * fileIndexOut) {
|
inline void ConstructGrid(DeallocatingVector<EdgeT> & edgeList, const char * ramIndexOut, const char * fileIndexOut) {
|
||||||
//TODO: Implement this using STXXL-Streams
|
//TODO: Implement this using STXXL-Streams
|
||||||
Percent p(edgeList.size());
|
Percent p(edgeList.size());
|
||||||
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
||||||
@ -316,6 +316,7 @@ private:
|
|||||||
return (std::fabs(d1 - d2) < FLT_EPSILON);
|
return (std::fabs(d1 - d2) < FLT_EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ROUTED
|
||||||
inline unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, const uint64_t fileOffset, boost::unordered_map< unsigned, unsigned > & cellMap ) {
|
inline unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, const uint64_t fileOffset, boost::unordered_map< unsigned, unsigned > & cellMap ) {
|
||||||
std::vector<char> tmpBuffer(32*32*4096,0);
|
std::vector<char> tmpBuffer(32*32*4096,0);
|
||||||
uint64_t indexIntoTmpBuffer = 0;
|
uint64_t indexIntoTmpBuffer = 0;
|
||||||
@ -393,6 +394,7 @@ private:
|
|||||||
vectorWithSameFileIndex.clear();
|
vectorWithSameFileIndex.clear();
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inline void GetContentsOfFileBucketEnumerated(const unsigned fileIndex, std::vector<_GridEdge>& result) const {
|
inline void GetContentsOfFileBucketEnumerated(const unsigned fileIndex, std::vector<_GridEdge>& result) const {
|
||||||
unsigned ramIndex = GetRAMIndexFromFileIndex(fileIndex);
|
unsigned ramIndex = GetRAMIndexFromFileIndex(fileIndex);
|
||||||
@ -578,9 +580,9 @@ private:
|
|||||||
|
|
||||||
const static uint64_t END_OF_BUCKET_DELIMITER = boost::integer_traits<uint64_t>::const_max;
|
const static uint64_t END_OF_BUCKET_DELIMITER = boost::integer_traits<uint64_t>::const_max;
|
||||||
|
|
||||||
std::ofstream indexOutFile;
|
|
||||||
std::ifstream ramInFile;
|
std::ifstream ramInFile;
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
|
std::ofstream indexOutFile;
|
||||||
stxxl::vector<GridEntry> entries;
|
stxxl::vector<GridEntry> entries;
|
||||||
#endif
|
#endif
|
||||||
std::vector<uint64_t> ramIndexTable; //8 MB for first level index in RAM
|
std::vector<uint64_t> ramIndexTable; //8 MB for first level index in RAM
|
||||||
|
@ -169,14 +169,14 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
edgeList[i]._source = UINT_MAX;
|
edgeList[i]._source = UINT_MAX;
|
||||||
} else {
|
} else {
|
||||||
//edge i-1 is open in both directions, but edge i is smaller in one direction. Close edge i-1 in this direction
|
//edge i-1 is open in both directions, but edge i is smaller in one direction. Close edge i-1 in this direction
|
||||||
edgeList[i-1].forward = ~edgeList[i].isForward();
|
edgeList[i-1].forward = !edgeList[i].isForward();
|
||||||
edgeList[i-1].backward = ~edgeList[i].isBackward();
|
edgeList[i-1].backward = !edgeList[i].isBackward();
|
||||||
}
|
}
|
||||||
} else if (edgeFlagsAreSuperSet2) {
|
} else if (edgeFlagsAreSuperSet2) {
|
||||||
if(edgeList[i-1].weight() <= edgeList[i].weight()) {
|
if(edgeList[i-1].weight() <= edgeList[i].weight()) {
|
||||||
//edge i-1 is smaller for one direction. edge i is open in both. close edge i in the other direction
|
//edge i-1 is smaller for one direction. edge i is open in both. close edge i in the other direction
|
||||||
edgeList[i].forward = ~edgeList[i-1].isForward();
|
edgeList[i].forward = !edgeList[i-1].isForward();
|
||||||
edgeList[i].backward = ~edgeList[i-1].isBackward();
|
edgeList[i].backward = !edgeList[i-1].isBackward();
|
||||||
} else {
|
} else {
|
||||||
//edge i is smaller and goes in both direction. Throw away edge i-1
|
//edge i is smaller and goes in both direction. Throw away edge i-1
|
||||||
edgeList[i-1]._source = UINT_MAX;
|
edgeList[i-1]._source = UINT_MAX;
|
||||||
|
@ -92,12 +92,12 @@ int main (int argc, char *argv[]) {
|
|||||||
ERR("Cannot open " << argv[1]);
|
ERR("Cannot open " << argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
char nodeOut[1024]; strcpy(nodeOut, argv[1]); strcat(nodeOut, ".nodes");
|
std::string nodeOut(argv[1]); nodeOut += ".nodes";
|
||||||
char edgeOut[1024]; strcpy(edgeOut, argv[1]); strcat(edgeOut, ".edges");
|
std::string edgeOut(argv[1]); edgeOut += ".edges";
|
||||||
char graphOut[1024]; strcpy(graphOut, argv[1]); strcat(graphOut, ".hsgr");
|
std::string graphOut(argv[1]); graphOut += ".hsgr";
|
||||||
char ramIndexOut[1024]; strcpy(ramIndexOut, argv[1]); strcat(ramIndexOut, ".ramIndex");
|
std::string ramIndexOut(argv[1]); ramIndexOut += ".ramIndex";
|
||||||
char fileIndexOut[1024]; strcpy(fileIndexOut, argv[1]); strcat(fileIndexOut, ".fileIndex");
|
std::string fileIndexOut(argv[1]); fileIndexOut += ".fileIndex";
|
||||||
char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels");
|
std::string levelInfoOut(argv[1]); levelInfoOut += ".levels";
|
||||||
|
|
||||||
/*** Setup Scripting Environment ***/
|
/*** Setup Scripting Environment ***/
|
||||||
if(!testDataFile( (argc > 3 ? argv[3] : "profile.lua") )) {
|
if(!testDataFile( (argc > 3 ? argv[3] : "profile.lua") )) {
|
||||||
@ -150,7 +150,7 @@ int main (int argc, char *argv[]) {
|
|||||||
INFO("Generating edge-expanded graph representation");
|
INFO("Generating edge-expanded graph representation");
|
||||||
EdgeBasedGraphFactory * edgeBasedGraphFactory = new EdgeBasedGraphFactory (nodeBasedNodeNumber, edgeList, bollardNodes, trafficLightNodes, inputRestrictions, internalToExternalNodeMapping, speedProfile);
|
EdgeBasedGraphFactory * edgeBasedGraphFactory = new EdgeBasedGraphFactory (nodeBasedNodeNumber, edgeList, bollardNodes, trafficLightNodes, inputRestrictions, internalToExternalNodeMapping, speedProfile);
|
||||||
std::vector<ImportEdge>().swap(edgeList);
|
std::vector<ImportEdge>().swap(edgeList);
|
||||||
edgeBasedGraphFactory->Run(edgeOut);
|
edgeBasedGraphFactory->Run(edgeOut.c_str());
|
||||||
std::vector<_Restriction>().swap(inputRestrictions);
|
std::vector<_Restriction>().swap(inputRestrictions);
|
||||||
std::vector<NodeID>().swap(bollardNodes);
|
std::vector<NodeID>().swap(bollardNodes);
|
||||||
std::vector<NodeID>().swap(trafficLightNodes);
|
std::vector<NodeID>().swap(trafficLightNodes);
|
||||||
@ -163,7 +163,7 @@ int main (int argc, char *argv[]) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
INFO("writing node map ...");
|
INFO("writing node map ...");
|
||||||
std::ofstream mapOutFile(nodeOut, std::ios::binary);
|
std::ofstream mapOutFile(nodeOut.c_str(), std::ios::binary);
|
||||||
mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo));
|
mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo));
|
||||||
mapOutFile.close();
|
mapOutFile.close();
|
||||||
std::vector<NodeInfo>().swap(internalToExternalNodeMapping);
|
std::vector<NodeInfo>().swap(internalToExternalNodeMapping);
|
||||||
@ -186,7 +186,7 @@ int main (int argc, char *argv[]) {
|
|||||||
|
|
||||||
INFO("building grid ...");
|
INFO("building grid ...");
|
||||||
WritableGrid * writeableGrid = new WritableGrid();
|
WritableGrid * writeableGrid = new WritableGrid();
|
||||||
writeableGrid->ConstructGrid(nodeBasedEdgeList, ramIndexOut, fileIndexOut);
|
writeableGrid->ConstructGrid(nodeBasedEdgeList, ramIndexOut.c_str(), fileIndexOut.c_str());
|
||||||
delete writeableGrid;
|
delete writeableGrid;
|
||||||
IteratorbasedCRC32<DeallocatingVector<EdgeBasedGraphFactory::EdgeBasedNode> > crc32;
|
IteratorbasedCRC32<DeallocatingVector<EdgeBasedGraphFactory::EdgeBasedNode> > crc32;
|
||||||
unsigned crc32OfNodeBasedEdgeList = crc32(nodeBasedEdgeList.begin(), nodeBasedEdgeList.end() );
|
unsigned crc32OfNodeBasedEdgeList = crc32(nodeBasedEdgeList.begin(), nodeBasedEdgeList.end() );
|
||||||
@ -216,7 +216,7 @@ int main (int argc, char *argv[]) {
|
|||||||
unsigned numberOfNodes = 0;
|
unsigned numberOfNodes = 0;
|
||||||
unsigned numberOfEdges = contractedEdgeList.size();
|
unsigned numberOfEdges = contractedEdgeList.size();
|
||||||
INFO("Serializing compacted graph");
|
INFO("Serializing compacted graph");
|
||||||
std::ofstream edgeOutFile(graphOut, std::ios::binary);
|
std::ofstream edgeOutFile(graphOut.c_str(), std::ios::binary);
|
||||||
|
|
||||||
BOOST_FOREACH(QueryEdge & edge, contractedEdgeList) {
|
BOOST_FOREACH(QueryEdge & edge, contractedEdgeList) {
|
||||||
if(edge.source > numberOfNodes) {
|
if(edge.source > numberOfNodes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user