summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-08-04 05:06:02 (GMT)
committerJohn Denker <jsd@av8n.com>2012-12-02 18:55:48 (GMT)
commit0613441985e203b94f5afbbd599cb33d8c7c7cbe (patch)
tree65eb01d86ac0d17032ac8ce9488f9a4679899278
parent6c0926be32e890baba2cac29c5398e82a49c7ab1 (diff)
enormous simplification
-rw-r--r--tools/bad_thing.h35
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