[Liblas-commits] r1338 - trunk/src

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 13 20:27:34 EDT 2009


Author: mloskot
Date: Thu Aug 13 20:27:33 2009
New Revision: 1338
URL: http://liblas.org/changeset/1338

Log:
Fixed compilation warnings. Added FIXME comment about potential memory leak. Added missing whitespaces between ops and operands.

Modified:
   trunk/src/lasvariablerecord.cpp

Modified: trunk/src/lasvariablerecord.cpp
==============================================================================
--- trunk/src/lasvariablerecord.cpp	(original)
+++ trunk/src/lasvariablerecord.cpp	Thu Aug 13 20:27:33 2009
@@ -220,15 +220,16 @@
 std::ostream& operator << ( std::ostream& out, LASVariableRecord const& d)
 {
     // std::vector<uint8_t> data = d.GetData();
-    std::streampos begin = out.tellp();
+    std::streampos const begin = out.tellp();
     std::cout << "begin: " << begin << std::endl;
-    std::cout << "Dumping " << d.GetRecordLength() <<" bytes out for VLR" << "Size is : " << d.GetData().size() <<std::endl;
-    for (std::size_t i=0;i<d.GetData().size();i++)
+    std::cout << "Dumping " << d.GetRecordLength() 
+        <<" bytes out for VLR" << "Size is : " << d.GetData().size() <<std::endl;
+    for (std::size_t i = 0; i < d.GetData().size(); ++i)
     {
         //        out << d.GetData()[i];
     }
     out << &(d.GetData()[0]);
-    std::streampos end = out.tellp();
+    std::streampos const end = out.tellp();
     std::cout << "end: " << end << std::endl;
 
     return out;
@@ -236,13 +237,14 @@
 
 std::istream& operator >> ( std::istream& in, LASVariableRecord& d)
 {
-    std::streampos input_pos = in.tellg();
-    std::vector<uint8_t> data;
+    std::streampos const input_pos = in.tellg();
     in.seekg(0, std::ios::end);
-    std::streampos length = in.tellg();
+    std::streampos const length = in.tellg();
     in.seekg(input_pos, std::ios::beg);
     std::cout << "Stream length: " << length << std::endl;
     
+    // FIXME: If read_n throws, buffer will leak.
+    //        Replace with std::vector --mloskot
     uint8_t* buffer = new uint8_t[length];
 
     liblas::detail::read_n(buffer, in, length);
@@ -253,7 +255,9 @@
     //         and we don't know the orientation of the bytes - hobu
     LIBLAS_SWAP_BYTES_N(buffer, length);
     
-    for (std::size_t i=0; i < length; i++){
+    std::vector<uint8_t> data;
+    for (std::size_t i = 0; i < static_cast<std::size_t>(length); ++i)
+    {
         data.push_back(buffer[i]);
     }
     delete buffer;
@@ -261,5 +265,6 @@
     d.SetData(data);
     return in;
 }
+
 } // namespace liblas
 


More information about the Liblas-commits mailing list