]> git.cworth.org Git - apitrace/blobdiff - common/trace_file_snappy.cpp
Use appropriate number of digits when dumping floating point numbers.
[apitrace] / common / trace_file_snappy.cpp
index 4d4ecea7a73c8f4251a59116af61b7636db78402..c0727cd28e86df4e54573e7094e7125cd91053a2 100644 (file)
@@ -82,7 +82,7 @@ public:
 protected:
     virtual bool rawOpen(const std::string &filename, File::Mode mode);
     virtual bool rawWrite(const void *buffer, size_t length);
-    virtual bool rawRead(void *buffer, size_t length);
+    virtual size_t rawRead(void *buffer, size_t length);
     virtual int rawGetc();
     virtual void rawClose();
     virtual void rawFlush();
@@ -141,6 +141,7 @@ SnappyFile::SnappyFile(const std::string &filename,
 
 SnappyFile::~SnappyFile()
 {
+    close();
     delete [] m_compressedCache;
     delete [] m_cache;
 }
@@ -208,10 +209,10 @@ bool SnappyFile::rawWrite(const void *buffer, size_t length)
     return true;
 }
 
-bool SnappyFile::rawRead(void *buffer, size_t length)
+size_t SnappyFile::rawRead(void *buffer, size_t length)
 {
     if (endOfData()) {
-        return false;
+        return 0;
     }
 
     if (freeCacheSize() >= length) {
@@ -230,18 +231,18 @@ bool SnappyFile::rawRead(void *buffer, size_t length)
                 flushReadCache();
             }
             if (!m_cacheSize) {
-                break;
+                return length - sizeToRead;
             }
         }
     }
 
-    return true;
+    return length;
 }
 
 int SnappyFile::rawGetc()
 {
-    int c = 0;
-    if (!rawRead(&c, 1))
+    unsigned char c = 0;
+    if (rawRead(&c, 1) != 1)
         return -1;
     return c;
 }