From 0613441985e203b94f5afbbd599cb33d8c7c7cbe Mon Sep 17 00:00:00 2001 From: John Denker Date: Fri, 3 Aug 2012 22:06:02 -0700 Subject: enormous simplification --- tools/bad_thing.h | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'tools') 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 -- cgit v1.2.3