diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-05 05:53:36 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-05 05:53:36 -0600 |
commit | 036200e959db6a3b9fe0d02f9eec3eb131983ab4 (patch) | |
tree | 02e86d54089da915cb98e3752c3cf77410ab25c4 /src/format.h | |
parent | 96ec764c4ad31e3d66782775fcc6885ad0818111 (diff) | |
download | fork-ledger-036200e959db6a3b9fe0d02f9eec3eb131983ab4.tar.gz fork-ledger-036200e959db6a3b9fe0d02f9eec3eb131983ab4.tar.bz2 fork-ledger-036200e959db6a3b9fe0d02f9eec3eb131983ab4.zip |
Make copying of format_t objects memory-safe
Diffstat (limited to 'src/format.h')
-rw-r--r-- | src/format.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/format.h b/src/format.h index 0073b427..1b8513bb 100644 --- a/src/format.h +++ b/src/format.h @@ -51,7 +51,7 @@ class unistring; DECLARE_EXCEPTION(format_error, std::runtime_error); -class format_t : public expr_base_t<string> +class format_t : public expr_base_t<string>, public noncopyable { typedef expr_base_t<string> base_type; @@ -65,14 +65,12 @@ class format_t : public expr_base_t<string> std::size_t min_width; std::size_t max_width; variant<string, expr_t> data; - scoped_ptr<struct element_t> next; + shared_ptr<struct element_t> next; element_t() throw() : supports_flags<>(), type(STRING), min_width(0), max_width(0) { TRACE_CTOR(element_t, ""); } - element_t(const element_t& elem); - ~element_t() throw() { TRACE_DTOR(element_t); } @@ -84,6 +82,7 @@ class format_t : public expr_base_t<string> min_width = elem.min_width; max_width = elem.max_width; data = elem.data; + next = elem.next; } return *this; } @@ -105,7 +104,7 @@ class format_t : public expr_base_t<string> void dump(std::ostream& out) const; }; - scoped_ptr<element_t> elements; + shared_ptr<element_t> elements; public: static enum elision_style_t { |