lemon/lgf_writer.h
changeset 297 92b193385702
parent 294 cbe3ec2d59d2
child 303 a3a69f5bba62
     1.1 --- a/lemon/lgf_writer.h	Sun Oct 05 12:36:26 2008 +0200
     1.2 +++ b/lemon/lgf_writer.h	Mon Oct 06 11:01:03 2008 +0100
     1.3 @@ -463,7 +463,10 @@
     1.4      DigraphWriter(const Digraph& digraph, const std::string& fn)
     1.5        : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
     1.6          _skip_nodes(false), _skip_arcs(false) {
     1.7 -      if (!(*_os)) throw IoError("Cannot write file", fn);
     1.8 +      if (!(*_os)) {
     1.9 +        delete _os;
    1.10 +        throw IoError("Cannot write file", fn);
    1.11 +      }
    1.12      }
    1.13  
    1.14      /// \brief Constructor
    1.15 @@ -473,7 +476,10 @@
    1.16      DigraphWriter(const Digraph& digraph, const char* fn)
    1.17        : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    1.18          _skip_nodes(false), _skip_arcs(false) {
    1.19 -      if (!(*_os)) throw IoError("Cannot write file", fn);
    1.20 +      if (!(*_os)) {
    1.21 +        delete _os;
    1.22 +        throw IoError("Cannot write file", fn);
    1.23 +      }
    1.24      }
    1.25  
    1.26      /// \brief Destructor
    1.27 @@ -1024,7 +1030,10 @@
    1.28      GraphWriter(const Graph& graph, const std::string& fn)
    1.29        : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    1.30          _skip_nodes(false), _skip_edges(false) {
    1.31 -      if (!(*_os)) throw IoError("Cannot write file", fn);
    1.32 +      if (!(*_os)) {
    1.33 +        delete _os;
    1.34 +        throw IoError("Cannot write file", fn);
    1.35 +      }
    1.36      }
    1.37  
    1.38      /// \brief Constructor
    1.39 @@ -1034,7 +1043,10 @@
    1.40      GraphWriter(const Graph& graph, const char* fn)
    1.41        : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    1.42          _skip_nodes(false), _skip_edges(false) {
    1.43 -      if (!(*_os)) throw IoError("Cannot write file", fn);
    1.44 +      if (!(*_os)) {
    1.45 +        delete _os;
    1.46 +        throw IoError("Cannot write file", fn);
    1.47 +      }
    1.48      }
    1.49  
    1.50      /// \brief Destructor
    1.51 @@ -1587,7 +1599,10 @@
    1.52      /// Construct a section writer, which writes into the given file.
    1.53      SectionWriter(const std::string& fn)
    1.54        : _os(new std::ofstream(fn.c_str())), local_os(true) {
    1.55 -      if (!(*_os)) throw IoError("Cannot write file", fn);
    1.56 +      if (!(*_os)) {
    1.57 +        delete _os;
    1.58 +        throw IoError("Cannot write file", fn);
    1.59 +      }
    1.60      }
    1.61  
    1.62      /// \brief Constructor
    1.63 @@ -1595,7 +1610,10 @@
    1.64      /// Construct a section writer, which writes into the given file.
    1.65      SectionWriter(const char* fn)
    1.66        : _os(new std::ofstream(fn)), local_os(true) {
    1.67 -      if (!(*_os)) throw IoError("Cannot write file", fn);
    1.68 +      if (!(*_os)) {
    1.69 +        delete _os;
    1.70 +        throw IoError("Cannot write file", fn);
    1.71 +      }
    1.72      }
    1.73  
    1.74      /// \brief Destructor