From 036200e959db6a3b9fe0d02f9eec3eb131983ab4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 5 Mar 2012 05:53:36 -0600 Subject: Make copying of format_t objects memory-safe --- src/format.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/format.h') 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 +class format_t : public expr_base_t, public noncopyable { typedef expr_base_t base_type; @@ -65,14 +65,12 @@ class format_t : public expr_base_t std::size_t min_width; std::size_t max_width; variant data; - scoped_ptr next; + shared_ptr 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 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 void dump(std::ostream& out) const; }; - scoped_ptr elements; + shared_ptr elements; public: static enum elision_style_t { -- cgit v1.2.3