diff options
-rw-r--r-- | tools/bad_thing.h | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/tools/bad_thing.h b/tools/bad_thing.h index ee988dc..578170e 100644 --- a/tools/bad_thing.h +++ b/tools/bad_thing.h @@ -7,39 +7,20 @@ public: }; class bad_thing: public std::exception{ - payloader* load; - char* &raw; + std::string msg; public: virtual const char* what() const throw() { - return load->str; - } - bad_thing(); -// copy constructor. -// It's OK to copy a pointer to the refcount, -// but it would not be OK to copy the refcount! - bad_thing(const bad_thing &other) - : load(other.load), raw((char*&) load) - { - load->refcount++; - //xx std::cerr << "Copied! --> " << load->refcount << std::endl; + return msg.c_str(); } - bad_thing(const std::string msg) - : raw((char*&) load) - { - size_t len = msg.size(); - raw = new char[1+len + sizeof(payloader)]; - load->refcount = 1; - for (unsigned int ii = 0; ii < len; ii++){ - load->str[ii] = msg[ii]; - } - load->str[len] = 0; - } +// constructor + bad_thing(const std::string _msg) + : msg(_msg) + {} + +// destructor ~bad_thing() throw() { - if (--load->refcount) return; - //xx std::cerr << "delete!" << std::endl; - delete[] raw; } }; #endif |