From 9c763a8c5863bd7a576cfe67c38672a0cf71b06a Mon Sep 17 00:00:00 2001 From: graehl Date: Wed, 21 Jul 2010 02:54:09 +0000 Subject: vest generate options valgrind fix git-svn-id: https://ws10smt.googlecode.com/svn/trunk@352 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/filelib.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'decoder/filelib.h') diff --git a/decoder/filelib.h b/decoder/filelib.h index 85e1c29a..9f6bd0a9 100644 --- a/decoder/filelib.h +++ b/decoder/filelib.h @@ -58,9 +58,10 @@ class ReadFile : public BaseFile { std::cerr << "File does not exist: " << filename << std::endl; abort(); } + char const* file=filename_.c_str(); // just in case the gzstream keeps using the filename for longer than the constructor, e.g. inflateReset2. warning in valgrind that I'm hoping will disappear - it makes no sense. ps_.reset(EndsWith(filename, ".gz") ? - static_cast(new igzstream(filename.c_str())) : - static_cast(new std::ifstream(filename.c_str()))); + static_cast(new igzstream(file)) : + static_cast(new std::ifstream(file))); if (!*ps_) { std::cerr << "Failed to open " << filename << std::endl; abort(); @@ -79,9 +80,10 @@ class WriteFile : public BaseFile { if (is_std()) { ps_=PS(&std::cout,file_null_deleter()); } else { + char const* file=filename_.c_str(); // just in case the gzstream keeps using the filename for longer than the constructor, e.g. inflateReset2. warning in valgrind that I'm hoping will disappear - it makes no sense. ps_.reset(EndsWith(filename, ".gz") ? - static_cast(new ogzstream(filename.c_str())) : - static_cast(new std::ofstream(filename.c_str()))); + static_cast(new ogzstream(file)) : + static_cast(new std::ofstream(file))); if (!*ps_) { std::cerr << "Failed to open " << filename << std::endl; abort(); -- cgit v1.2.3