Skip to content

Commit

Permalink
Merge pull request #929 from PDAL/close-streams
Browse files Browse the repository at this point in the history
Clean up streams.
  • Loading branch information
connormanning committed May 28, 2015
2 parents ecdd02a + eb364b8 commit ab573da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 5 additions & 3 deletions io/las/LasReader.hpp
Expand Up @@ -57,10 +57,12 @@ class PDAL_DLL LasReader : public pdal::Reader
{
friend class NitfReader;
public:
LasReader() : pdal::Reader(), m_index(0),
m_istream(NULL)
LasReader() : pdal::Reader(), m_index(0), m_istream(NULL)
{}

virtual ~LasReader()
{ destroyStream(); }

static void * create();
static int32_t destroy(void *);
std::string getName() const;
Expand All @@ -79,7 +81,7 @@ class PDAL_DLL LasReader : public pdal::Reader
return m_istream;
}
virtual void destroyStream()
{ FileUtils::closeFile(m_istream); }
{ FileUtils::closeFile(m_istream); m_istream = NULL; }
private:
LasError m_error;
LasHeader m_lasHeader;
Expand Down
1 change: 1 addition & 0 deletions plugins/nitf/io/NitfReader.hpp
Expand Up @@ -73,6 +73,7 @@ typedef boost::iostreams::stream<RDevice> RStream;
m_rstream.reset();
m_rdevice.reset();
FileUtils::closeFile(m_istream);
m_istream = NULL;
}

private:
Expand Down
2 changes: 2 additions & 0 deletions plugins/oci/io/OciCommon.cpp
Expand Up @@ -71,6 +71,8 @@ Connection connect(std::string connSpec)
output = line;
}
connection = output;

FileUtils::closeFile(input);
}

Connection con;
Expand Down
9 changes: 6 additions & 3 deletions plugins/oci/io/OciWriter.cpp
Expand Up @@ -423,6 +423,9 @@ std::string OciWriter::loadSQLData(std::string const& filename)
else
output = line;
}

FileUtils::closeFile(input);

return output;
}

Expand Down Expand Up @@ -715,7 +718,7 @@ void OciWriter::processOptions(const Options& options)

if (m_compression && (m_orientation == Orientation::DimensionMajor))
throw pdal_error("LAZperf compression not supported for "
"dimension-major point storage.");
"dimension-major point storage.");
}


Expand Down Expand Up @@ -917,7 +920,7 @@ void OciWriter::writeTile(const PointViewPtr view)
if (usePartition)
oss << ", :9";
oss <<")";

Statement statement(m_connection->CreateStatement(oss.str().c_str()));

// :1
Expand All @@ -940,7 +943,7 @@ void OciWriter::writeTile(const PointViewPtr view)

//NOTE: packed point size is guaranteed to be of sufficient size to hold
// a point's data, but it may be larger than the actual size of a point
// if location scaling is being used.
// if location scaling is being used.
std::vector<char> outbuf(packedPointSize() * view->size());
size_t totalSize = 0;
if (m_orientation == Orientation::DimensionMajor)
Expand Down

0 comments on commit ab573da

Please sign in to comment.