Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Fixes issue Project-OSRM#73.
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisOSRM committed Jan 31, 2012
1 parent f68d53e commit 8a665bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
19 changes: 10 additions & 9 deletions DataStructures/PBFParser.h
Expand Up @@ -358,7 +358,7 @@ class PBFParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
}

void loadBlock(_ThreadData * threadData) {
blockCount++;
++blockCount;
threadData->currentGroupID = 0;
threadData->currentEntityID = 0;
}
Expand All @@ -380,14 +380,14 @@ class PBFParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
if ( size > MAX_BLOB_HEADER_SIZE || size < 0 ) {
return false;
}
char *data = (char*)malloc(size);
char *data = new char[size];
stream.read(data, size*sizeof(data[0]));

if ( !(threadData->PBFBlobHeader).ParseFromArray( data, size ) ){
free(data);
delete[] data;
return false;
}
free(data);
delete[] data;
return true;
}

Expand Down Expand Up @@ -487,25 +487,26 @@ class PBFParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
return false;
}

if ( !readPBFBlobHeader(stream, threadData) )
if ( !readPBFBlobHeader(stream, threadData) ){
return false;
}

if ( threadData->PBFBlobHeader.type() != "OSMData" ) {
std::cerr << "[error] invalid block type, found" << threadData->PBFBlobHeader.type().data() << "instead of OSMData" << std::endl;
return false;
}

if ( !readBlob(stream, threadData) )
if ( !readBlob(stream, threadData) ) {
return false;
}

if ( !threadData->PBFprimitiveBlock.ParseFromArray( &(threadData->charBuffer[0]), threadData-> charBuffer.size() ) ) {
std::cerr << "[error] failed to parse PrimitiveBlock" << std::endl;
ERR("failed to parse PrimitiveBlock");
return false;
}
return true;
}

static Endianness getMachineEndianness() {
Endianness getMachineEndianness() const {
int i(1);
char *p = (char *) &i;
if (p[0] == 1)
Expand Down
11 changes: 6 additions & 5 deletions extractor.cpp
Expand Up @@ -60,7 +60,7 @@ unsigned globalRestrictionCounter = 0;
ExtractorCallbacks * extractCallBacks;

bool nodeFunction(_Node n);
bool adressFunction(_Node n, HashTable<string, string> keyVals);
bool adressFunction(_Node n, HashTable<string, string> & keyVals);
bool restrictionFunction(_RawRestrictionContainer r);
bool wayFunction(_Way w);

Expand Down Expand Up @@ -190,10 +190,9 @@ int main (int argc, char *argv[]) {
parser = new XMLParser(argv[1]);
}
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
GUARANTEE(parser->Init(), "Parser not initialized!");
if(!parser->Init())
INFO("Parser not initialized!");
parser->Parse();
DELETE(parser);
stringMap.clear();

try {
// INFO("raw no. of names: " << externalMemory.nameVector.size());
Expand Down Expand Up @@ -485,7 +484,9 @@ int main (int argc, char *argv[]) {
cerr << "Caught Execption:" << e.what() << endl;
return false;
}
DELETE(parser);

stringMap.clear();
delete extractCallBacks;
cout << "[extractor] finished." << endl;
return 0;
Expand All @@ -496,7 +497,7 @@ bool nodeFunction(_Node n) {
return true;
}

bool adressFunction(_Node n, HashTable<string, string> keyVals){
bool adressFunction(_Node n, HashTable<string, string> & keyVals){
extractCallBacks->adressFunction(n, keyVals);
return true;
}
Expand Down

0 comments on commit 8a665bc

Please sign in to comment.