Skip to content

Commit

Permalink
Fix iterator checking assertions on Windows debug version
Browse files Browse the repository at this point in the history
  • Loading branch information
alex85k committed May 7, 2014
1 parent 9d567af commit 334f1f0
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 56 deletions.
1 change: 1 addition & 0 deletions Contractor/EdgeBasedGraphFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void EdgeBasedGraphFactory::FlushVectorToStream(
std::ofstream & edge_data_file,
std::vector<OriginalEdgeData> & original_edge_data_vector
) const {
if (original_edge_data_vector.empty()) return;
edge_data_file.write(
(char*)&(original_edge_data_vector[0]),
original_edge_data_vector.size()*sizeof(OriginalEdgeData)
Expand Down
4 changes: 3 additions & 1 deletion DataStructures/StaticRTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ class StaticRTree : boost::noncopyable
tree_node_file.read((char *)&tree_size, sizeof(uint32_t));

m_search_tree.resize(tree_size);
tree_node_file.read((char *)&m_search_tree[0], sizeof(TreeNode) * tree_size);
if (tree_size > 0) {
tree_node_file.read((char *)&m_search_tree[0], sizeof(TreeNode) * tree_size);
}
tree_node_file.close();
// open leaf node file and store thread specific pointer
if (!boost::filesystem::exists(leaf_file))
Expand Down
9 changes: 7 additions & 2 deletions Descriptors/JSONDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,13 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
shortest_segment_2 = shortestDifference[i];
}
}

std::set_difference(alternative_path_segments.begin(),
std::sort(shortest_path_segments.begin(),
shortest_path_segments.end(),
name_id_comperator);
std::sort(alternative_path_segments.begin(),
alternative_path_segments.end(),
name_id_comperator);
std::set_difference(alternative_path_segments.begin(),
alternative_path_segments.end(),
shortest_path_segments.begin(),
shortest_path_segments.end(),
Expand Down
42 changes: 25 additions & 17 deletions Server/DataStructures/InternalDataFacade.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
sizeof(unsigned)
);

m_geometry_indices.resize(number_of_indices);
geometry_stream.read(
(char *)&(m_geometry_indices[0]),
number_of_indices*sizeof(unsigned)
);
m_geometry_indices.resize(number_of_indices);
if (number_of_indices > 0) {
geometry_stream.read(
(char *)&(m_geometry_indices[0]),
number_of_indices*sizeof(unsigned)
);
}

geometry_stream.read(
(char *)&number_of_compressed_geometries,
Expand All @@ -210,10 +212,12 @@ class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
BOOST_ASSERT( m_geometry_indices.back() == number_of_compressed_geometries );
m_geometry_list.resize( number_of_compressed_geometries );

geometry_stream.read(
(char *)&(m_geometry_list[0]),
number_of_compressed_geometries*sizeof(unsigned)
);
if (number_of_compressed_geometries > 0) {
geometry_stream.read(
(char *)&(m_geometry_list[0]),
number_of_compressed_geometries*sizeof(unsigned)
);
}
geometry_stream.close();
}

Expand Down Expand Up @@ -245,16 +249,20 @@ class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");

m_name_begin_indices.resize(number_of_names);
name_stream.read(
(char*)&m_name_begin_indices[0],
number_of_names*sizeof(unsigned)
);
if (number_of_names > 0) {
name_stream.read(
(char*)&m_name_begin_indices[0],
number_of_names*sizeof(unsigned)
);
}

m_names_char_list.resize(number_of_chars+1); //+1 gives sentinel element
name_stream.read(
(char *)&m_names_char_list[0],
number_of_chars*sizeof(char)
);
if (number_of_chars > 0) {
name_stream.read(
(char *)&m_names_char_list[0],
number_of_chars*sizeof(char)
);
}
BOOST_ASSERT_MSG(
0 != m_names_char_list.size(),
"could not load any names"
Expand Down
6 changes: 4 additions & 2 deletions Tools/componentAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ int main(int argc, char *argv[])
restriction_ifstream.read((char *)&usable_restriction_count, sizeof(uint32_t));
restrictions_vector.resize(usable_restriction_count);

restriction_ifstream.read((char *)&(restrictions_vector[0]),
usable_restriction_count * sizeof(TurnRestriction));
if (usable_restriction_count>0) {
restriction_ifstream.read((char *)&(restrictions_vector[0]),
usable_restriction_count * sizeof(TurnRestriction));
}
restriction_ifstream.close();

std::ifstream input_stream;
Expand Down
4 changes: 3 additions & 1 deletion Util/GraphLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ unsigned readHSGRFromStream(const boost::filesystem::path &hsgr_file,
hsgr_input_stream.read((char *)&(node_list[0]), number_of_nodes * sizeof(NodeT));

edge_list.resize(number_of_edges);
hsgr_input_stream.read((char *)&(edge_list[0]), number_of_edges * sizeof(EdgeT));
if (number_of_edges > 0) {
hsgr_input_stream.read((char *)&(edge_list[0]), number_of_edges * sizeof(EdgeT));
}
hsgr_input_stream.close();

return number_of_nodes;
Expand Down
20 changes: 12 additions & 8 deletions Util/UUID.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ UUIDC::UUIDC() : magic_number(1297240911) {
std::string temp_string(__DATE__);
temp_string += __TIME__;

std::copy(MD5PREPARE, MD5PREPARE+strlen(MD5PREPARE), md5_prepare);
temp_string += md5_prepare;
std::copy(MD5RTREE, MD5RTREE+32, md5_tree);
temp_string += md5_tree;
std::copy(MD5GRAPH, MD5GRAPH+32, md5_graph);
temp_string += md5_graph;
std::copy(MD5OBJECTS, MD5OBJECTS+32, md5_objects);
temp_string += md5_objects;
char *cMD5PREPARE = MD5PREPARE;
std::copy(cMD5PREPARE, cMD5PREPARE+strlen(cMD5PREPARE), md5_prepare);
temp_string += md5_prepare;
char *cMD5RTREE = MD5RTREE;
std::copy(cMD5RTREE, cMD5RTREE+32, md5_tree);
temp_string += md5_tree;
char *cMD5GRAPH = MD5GRAPH;
std::copy(cMD5GRAPH, cMD5GRAPH+32, md5_graph);
temp_string += md5_graph;
char *cMD5OBJECTS = MD5OBJECTS;
std::copy(cMD5OBJECTS, cMD5OBJECTS+32, md5_objects);
temp_string += md5_objects;

named_uuid = gen(temp_string);
has_64_bits = HAS64BITS;
Expand Down
47 changes: 27 additions & 20 deletions datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,20 @@ int main( const int argc, const char * argv[] )
unsigned * name_index_ptr = (unsigned*)(
shared_memory_ptr + shared_layout_ptr->GetNameIndexOffset()
);

name_stream.read(
(char*)name_index_ptr,
shared_layout_ptr->name_index_list_size*sizeof(unsigned)
);
if (shared_layout_ptr->name_index_list_size > 0) {
name_stream.read(
(char*)name_index_ptr,
shared_layout_ptr->name_index_list_size*sizeof(unsigned)
);
}

char * name_char_ptr = shared_memory_ptr + shared_layout_ptr->GetNameListOffset();
name_stream.read(
name_char_ptr,
shared_layout_ptr->name_char_list_size*sizeof(char)
);
if (shared_layout_ptr->name_char_list_size > 0) {
name_stream.read(
name_char_ptr,
shared_layout_ptr->name_char_list_size*sizeof(char)
);
}
name_stream.close();

//load original edge information
Expand Down Expand Up @@ -370,11 +373,12 @@ int main( const int argc, const char * argv[] )
geometry_input_stream.seekg(0, geometry_input_stream.beg);
geometry_input_stream.read((char *)&temporary_value, sizeof(unsigned));
BOOST_ASSERT(temporary_value == shared_layout_ptr->geometries_index_list_size);

geometry_input_stream.read(
(char *)geometries_index_ptr,
shared_layout_ptr->geometries_index_list_size*sizeof(unsigned)
);
if (shared_layout_ptr->geometries_index_list_size > 0) {
geometry_input_stream.read(
(char *)geometries_index_ptr,
shared_layout_ptr->geometries_index_list_size*sizeof(unsigned)
);
}

unsigned * geometries_list_ptr = (unsigned *)(
shared_memory_ptr + shared_layout_ptr->GetGeometryListOffset()
Expand All @@ -383,10 +387,12 @@ int main( const int argc, const char * argv[] )
geometry_input_stream.read((char *)&temporary_value, sizeof(unsigned));
BOOST_ASSERT(temporary_value == shared_layout_ptr->geometries_list_size);

geometry_input_stream.read(
(char *)geometries_list_ptr,
shared_layout_ptr->geometries_list_size*sizeof(unsigned)
);
if (shared_layout_ptr->geometries_list_size > 0) {
geometry_input_stream.read(
(char *)geometries_list_ptr,
shared_layout_ptr->geometries_list_size*sizeof(unsigned)
);
}

// Loading list of coordinates
FixedPointCoordinate * coordinates_ptr = (FixedPointCoordinate *)(
Expand Down Expand Up @@ -414,8 +420,9 @@ int main( const int argc, const char * argv[] )
char * rtree_ptr = static_cast<char *>(
shared_memory_ptr + shared_layout_ptr->GetRSearchTreeOffset()
);

tree_node_file.read(rtree_ptr, sizeof(RTreeNode)*tree_size);
if (tree_size > 0) {
tree_node_file.read(rtree_ptr, sizeof(RTreeNode)*tree_size);
}
tree_node_file.close();

// load the nodes of the search graph
Expand Down
14 changes: 9 additions & 5 deletions prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ int main (int argc, char *argv[]) {
sizeof(unsigned)
);
inputRestrictions.resize(usableRestrictionsCounter);
restrictionsInstream.read(
(char *)&(inputRestrictions[0]),
usableRestrictionsCounter*sizeof(TurnRestriction)
);
if (usableRestrictionsCounter > 0) {
restrictionsInstream.read(
(char *)&(inputRestrictions[0]),
usableRestrictionsCounter*sizeof(TurnRestriction)
);
}
restrictionsInstream.close();

boost::filesystem::ifstream in;
Expand Down Expand Up @@ -384,7 +386,9 @@ int main (int argc, char *argv[]) {
//serialize number of edges
hsgr_output_stream.write((char*) &contracted_edge_count, sizeof(unsigned));
//serialize all nodes
hsgr_output_stream.write((char*) &node_array[0], sizeof(StaticGraph<EdgeData>::NodeArrayEntry)*node_array_size);
if (node_array_size > 0) {
hsgr_output_stream.write((char*) &node_array[0], sizeof(StaticGraph<EdgeData>::NodeArrayEntry)*node_array_size);
}
//serialize all edges

SimpleLogger().Write() << "Building edge array";
Expand Down

0 comments on commit 334f1f0

Please sign in to comment.