diff --git a/include/lsgrmGraphOperations.txx b/include/lsgrmGraphOperations.txx index 203063ce7ce2dc888e73f0b633b945ed4c92176f..b7ad8ca709c215c31359db010e1ee8d5e91169a7 100644 --- a/include/lsgrmGraphOperations.txx +++ b/include/lsgrmGraphOperations.txx @@ -1,5 +1,6 @@ //#include "lsgrmGraphOperations.h" -#include <unistd.h> +//#include <unistd.h> +#include <cstdio> namespace lsgrm { @@ -836,9 +837,9 @@ void ReadGraph(TSegmenter& segmenter, const std::string& nodesPath, const std::string& edgesPath) { - FILE * nodeStream = fopen(nodesPath.c_str(), "r"); + FILE * nodeStream = fopen(nodesPath.c_str(), "rb"); assert(nodeStream != NULL); - FILE * edgeStream = fopen(edgesPath.c_str(), "r"); + FILE * edgeStream = fopen(edgesPath.c_str(), "rb"); assert(edgeStream != NULL); segmenter.ReadGraph(nodeStream, edgeStream); diff --git a/include/lsgrmSegmenter.h b/include/lsgrmSegmenter.h index d0ab69d0255cbbd4e1fb34bd8ca026dfa0814ff2..fb6e78eeb3991e6260a1dbbf15a8724307c06bc0 100644 --- a/include/lsgrmSegmenter.h +++ b/include/lsgrmSegmenter.h @@ -87,12 +87,13 @@ public: std::size_t contourSize = node->m_Contour.size(); fwrite(&(contourSize), sizeof(contourSize), 1, nodeStream); - short moves[contourSize]; + std::vector<short> moves; + moves.reserve(contourSize); for(unsigned int b = 0; b < contourSize; b++) { moves[b] = node->m_Contour[b]; } - fwrite(moves, sizeof(short), contourSize, nodeStream); + fwrite(&moves.front(), sizeof(short), contourSize, nodeStream); } /* @@ -135,8 +136,9 @@ public: { std::size_t contourSize; fread(&(contourSize), sizeof(contourSize), 1, nodeStream); - short moves[contourSize]; - fread(&moves, sizeof(short), contourSize, nodeStream); + std::vector<short> moves; + moves.reserve(contourSize); + fread(&moves.front(), sizeof(short), contourSize, nodeStream); for(unsigned int b = 0; b < contourSize; b++) { node->m_Contour.push_back(moves[b]); @@ -236,7 +238,3 @@ public: } // end of namespace lsgrm #endif - - - -