Skip to content

Commit

Permalink
Revert "Proposed fix for coverity #29372" because of causing Segmenta…
Browse files Browse the repository at this point in the history
…tion

faults.
[ci skip]
This reverts commit c0b5cfa.
  • Loading branch information
tobbi committed Feb 28, 2015
1 parent c0b5cfa commit 219ec61
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 101 deletions.
43 changes: 0 additions & 43 deletions src/physfs/buffered_ifile_stream.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions src/physfs/buffered_ifile_stream.hpp

This file was deleted.

6 changes: 4 additions & 2 deletions src/physfs/ifile_stream.cpp
Expand Up @@ -16,8 +16,10 @@

#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))
{
}

Expand Down
4 changes: 1 addition & 3 deletions src/physfs/ifile_stream.hpp
Expand Up @@ -20,12 +20,10 @@
#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();
};

Expand Down
5 changes: 2 additions & 3 deletions src/physfs/physfs_file_system.cpp
Expand Up @@ -16,7 +16,7 @@

#include "physfs/physfs_file_system.hpp"

#include "physfs/buffered_ifile_stream.hpp"
#include "physfs/ifile_stream.hpp"

PhysFSFileSystem::PhysFSFileSystem()
{
Expand All @@ -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 */
5 changes: 2 additions & 3 deletions src/scripting/functions.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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)))
Expand Down
7 changes: 3 additions & 4 deletions src/scripting/scripting.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions src/supertux/console.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 219ec61

Please sign in to comment.