From fb5d8739b40292a30559ac8b2a6727e71519dcd8 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sat, 6 Aug 2011 19:06:34 -0400 Subject: [PATCH] Remove debugging helpers and fix Snappy::rawGetc --- trace_file.cpp | 58 ++++++-------------------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/trace_file.cpp b/trace_file.cpp index 4c6c8eb..0272a5c 100644 --- a/trace_file.cpp +++ b/trace_file.cpp @@ -21,11 +21,9 @@ File::File(const std::string &filename, } } -static size_t writtenRef = 0; File::~File() { - std::cerr << "written ref = "< length) { memcpy(m_cachePtr, buffer, length); m_cachePtr += length; @@ -216,19 +201,19 @@ bool SnappyFile::rawWrite(const void *buffer, int length) bool SnappyFile::rawRead(void *buffer, int length) { - std::cerr << "Reading byte = "<< (m_cachePtr - m_cache) << std::endl; + if (m_stream.eof()) { + return false; + } if (freeCacheSize() > length) { memcpy(buffer, m_cachePtr, length); m_cachePtr += length; } else if (freeCacheSize() == length) { memcpy(buffer, m_cachePtr, length); m_cachePtr += length; - assert(0); flushCache(); } else { int sizeToRead = length; int offset = 0; - assert(0); while (sizeToRead) { int chunkSize = std::min(freeCacheSize(), sizeToRead); offset = length - sizeToRead; @@ -245,17 +230,15 @@ bool SnappyFile::rawRead(void *buffer, int length) int SnappyFile::rawGetc() { - char c; - rawRead(&c, 1); + int c = 0; + if (!rawRead(&c, 1)) + return -1; return c; } void SnappyFile::rawClose() { flushCache(); - std::cerr << "written = "<< written - <<", comp = "<< writtenComp - << std::endl; m_stream.close(); delete [] m_cache; m_cache = NULL; @@ -272,27 +255,11 @@ void SnappyFile::flushCache() if (m_mode == File::Write) { size_t compressedLength; - static bool first = true; - if (first) { - std::cerr << "Buffer = ["; - for (int i = 0; i < 512; ++i) { - std::cerr << i << " ) "<< (int)m_cache[i] << std::endl; - } - std::cerr << "]"<