From: Wolfgang Bangerth Date: Tue, 25 Apr 2017 17:28:01 +0000 (-0600) Subject: Allow copying Patterns::List and Patterns::Map objects. X-Git-Tag: v9.0.0-rc1~1650^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d6c8a2b2484af8afdc76e828c67f37c306e5cb5;p=dealii.git Allow copying Patterns::List and Patterns::Map objects. Avoid the memory corruption that otherwise happens. --- diff --git a/include/deal.II/base/parameter_handler.h b/include/deal.II/base/parameter_handler.h index 739386d8f0..3eb4225351 100644 --- a/include/deal.II/base/parameter_handler.h +++ b/include/deal.II/base/parameter_handler.h @@ -414,6 +414,11 @@ namespace Patterns const unsigned int max_elements = max_int_value, const std::string &separator = ","); + /** + * Copy constructor. + */ + List (const List &other); + /** * Destructor. */ @@ -529,6 +534,11 @@ namespace Patterns const unsigned int max_elements = max_int_value, const std::string &separator = ","); + /** + * Copy constructor. + */ + Map (const Map &other); + /** * Destructor. */ diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 9573cbee36..d1c613e77f 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -587,6 +587,16 @@ namespace Patterns + List::List (const List &other) + : + pattern (other.pattern->clone()), + min_elements (other.min_elements), + max_elements (other.max_elements), + separator (other.separator) + {} + + + List::~List () { delete pattern; @@ -767,6 +777,17 @@ namespace Patterns + Map::Map (const Map &other) + : + key_pattern (other.key_pattern->clone()), + value_pattern (other.value_pattern->clone()), + min_elements (other.min_elements), + max_elements (other.max_elements), + separator (other.separator) + {} + + + Map::~Map () { delete key_pattern;