Revert "Proposed fix for coverity #29372" because of causing Segmentation
authorTobias Markus <tobbi@mozilla-uk.org>
Sat, 28 Feb 2015 16:12:48 +0000 (17:12 +0100)
committerTobias Markus <tobbi@mozilla-uk.org>
Sat, 28 Feb 2015 16:12:48 +0000 (17:12 +0100)
faults.
[ci skip]
This reverts commit c0b5cfa3eadebef8101f87cd593eb221bdef9280.

src/physfs/buffered_ifile_stream.cpp [deleted file]
src/physfs/buffered_ifile_stream.hpp [deleted file]
src/physfs/ifile_stream.cpp
src/physfs/ifile_stream.hpp
src/physfs/physfs_file_system.cpp
src/scripting/functions.cpp
src/scripting/scripting.cpp
src/supertux/console.cpp

diff --git a/src/physfs/buffered_ifile_stream.cpp b/src/physfs/buffered_ifile_stream.cpp
deleted file mode 100644 (file)
index 85eee6c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//  SuperTux
-//  Copyright (C) 2015 Tobias Markus <tobbi@mozilla-uk.org>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_PHYSFS_BUFFERED_IFILE_STREAM_CPP
-#define HEADER_SUPERTUX_PHYSFS_BUFFERED_IFILE_STREAM_CPP
-
-#include "physfs/buffered_ifile_stream.hpp"
-
-BufferedIFileStream::BufferedIFileStream(const std::string& filename)
-{
-  buffer = new IFileStreambuf(filename);
-  stream = new IFileStream(buffer);
-}
-
-BufferedIFileStream::~BufferedIFileStream()
-{
-  delete buffer;
-  delete stream;
-  buffer = NULL;
-  stream = NULL;
-}
-
-IFileStream* BufferedIFileStream::get_stream()
-{
-  return stream;
-}
-
-#endif
-
-/* EOF */
diff --git a/src/physfs/buffered_ifile_stream.hpp b/src/physfs/buffered_ifile_stream.hpp
deleted file mode 100644 (file)
index 578dd48..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//  SuperTux
-//  Copyright (C) 2015 Tobias Markus <tobbi@mozilla-uk.org>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_PHYSFS_BUFFERED_IFILE_STREAM_HPP
-#define HEADER_SUPERTUX_PHYSFS_BUFFERED_IFILE_STREAM_HPP
-
-#include <ostream>
-#include <physfs.h>
-#include "physfs/ifile_stream.hpp"
-#include "physfs/ifile_streambuf.hpp"
-
-class BufferedIFileStream {
-
-private:
-  IFileStream* stream;
-  IFileStreambuf* buffer;
-
-public:
-  BufferedIFileStream(const std::string& filename);
-  ~BufferedIFileStream();
-  
-  IFileStream* get_stream();
-};
-#endif
-
-/* EOF */
index f4cb889..4a09394 100644 (file)
 
 #include "physfs/ifile_stream.hpp"
 
-IFileStream::IFileStream(IFileStreambuf* buf) :
-  std::istream(buf)
+#include "physfs/ifile_streambuf.hpp"
+
+IFileStream::IFileStream(const std::string& filename) :
+  std::istream(new IFileStreambuf(filename))
 {
 }
 
index f160d1c..263e44d 100644 (file)
 #include <istream>
 #include <physfs.h>
 
-#include "physfs/ifile_streambuf.hpp"
-
 class IFileStream : public std::istream
 {
 public:
-  IFileStream(IFileStreambuf* buf);
+  IFileStream(const std::string& filename);
   ~IFileStream();
 };
 
index 65ac067..15d9f76 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "physfs/physfs_file_system.hpp"
 
-#include "physfs/buffered_ifile_stream.hpp"
+#include "physfs/ifile_stream.hpp"
 
 PhysFSFileSystem::PhysFSFileSystem()
 {
@@ -40,8 +40,7 @@ PhysFSFileSystem::open_directory(const std::string& pathname)
 std::unique_ptr<std::istream>
 PhysFSFileSystem::open_file(const std::string& filename)
 {
-  BufferedIFileStream* stream = new BufferedIFileStream(filename);
-  return std::unique_ptr<std::istream>(stream->get_stream());
+  return std::unique_ptr<std::istream>(new IFileStream(filename));
 }
 
 /* EOF */
index 2c906ff..893191b 100644 (file)
@@ -20,7 +20,7 @@
 #include "math/random_generator.hpp"
 #include "object/camera.hpp"
 #include "object/player.hpp"
-#include "physfs/buffered_ifile_stream.hpp"
+#include "physfs/ifile_stream.hpp"
 #include "supertux/fadeout.hpp"
 #include "supertux/game_session.hpp"
 #include "supertux/gameconfig.hpp"
@@ -127,8 +127,7 @@ void load_level(const std::string& filename)
 
 void import(HSQUIRRELVM vm, const std::string& filename)
 {
-  BufferedIFileStream* stream = new BufferedIFileStream(filename);
-  IFileStream* in = stream->get_stream();
+  IFileStream in(filename);
 
   if(SQ_FAILED(sq_compile(vm, squirrel_read_char, &in,
                           filename.c_str(), SQTrue)))
index b19c13b..1e27640 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "physfs/buffered_ifile_stream.hpp"
+#include "physfs/ifile_stream.hpp"
 #include "scripting/squirrel_error.hpp"
 #include "scripting/wrapper.hpp"
 #include "squirrel_util.hpp"
@@ -106,9 +106,8 @@ Scripting::Scripting(bool enable_debugger)
   // try to load default script
   try {
     std::string filename = "scripts/default.nut";
-    BufferedIFileStream* buffered_stream = new BufferedIFileStream(filename);
-    IFileStream* stream = buffered_stream->get_stream();
-    scripting::compile_and_run(global_vm, *stream, filename);
+    IFileStream stream(filename);
+    scripting::compile_and_run(global_vm, stream, filename);
   } catch(std::exception& e) {
     log_warning << "Couldn't load default.nut: " << e.what() << std::endl;
   }
index 7244191..1d27bc8 100644 (file)
@@ -19,7 +19,7 @@
 #include <math.h>
 #include <iostream>
 
-#include "physfs/buffered_ifile_stream.hpp"
+#include "physfs/ifile_stream.hpp"
 #include "scripting/scripting.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "supertux/gameconfig.hpp"
@@ -175,9 +175,8 @@ Console::ready_vm()
 
     try {
       std::string filename = "scripts/console.nut";
-      BufferedIFileStream* buffered_stream = new BufferedIFileStream(filename);
-      IFileStream* stream = buffered_stream->get_stream();
-      scripting::compile_and_run(m_vm, *stream, filename);
+      IFileStream stream(filename);
+      scripting::compile_and_run(m_vm, stream, filename);
     } catch(std::exception& e) {
       log_warning << "Couldn't load console.nut: " << e.what() << std::endl;
     }