From 2e998a6832fca188b3db79f3d1ce7872766c3015 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 24 May 2019 23:09:03 +0100 Subject: [PATCH] Fixed bug in 'vector of pointers' move constructor --- include/etl/private/ivectorpointer.h | 36 ++++++++++++++++++++++++++++ include/etl/vector.h | 4 ++-- include/etl/version.h | 2 +- support/Release notes.txt | 4 ++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index a24f2bad..eef997f2 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -435,6 +435,24 @@ namespace etl : pvoidvector(reinterpret_cast(p_buffer_), MAX_SIZE_) { } + + //********************************************************************* + /// Initialise the source vector after a move. + //********************************************************************* + void initialise_source_external_buffer_after_move() + { + ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + + p_end = p_buffer; + } + + //********************************************************************* + /// Initialise the destination vector after a move. + //********************************************************************* + void initialise_destination_external_buffer_after_move() + { + ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + } }; template @@ -828,6 +846,24 @@ namespace etl : pvoidvector(reinterpret_cast(const_cast(p_buffer_)), MAX_SIZE_) { } + + //********************************************************************* + /// Initialise the source vector after a move. + //********************************************************************* + void initialise_source_external_buffer_after_move() + { + ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + + p_end = p_buffer; + } + + //********************************************************************* + /// Initialise the destination vector after a move. + //********************************************************************* + void initialise_destination_external_buffer_after_move() + { + ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + } }; //*************************************************************************** diff --git a/include/etl/vector.h b/include/etl/vector.h index 5c3ecc63..1545c321 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -1555,7 +1555,7 @@ namespace etl { this->initialise(); - typename etl::ivector::iterator itr = other.begin(); + typename etl::ivector::iterator itr = other.begin(); while (itr != other.end()) { this->push_back(std::move(*itr)); @@ -1574,7 +1574,7 @@ namespace etl if (&rhs != this) { this->clear(); - typename etl::ivector::iterator itr = rhs.begin(); + typename etl::ivector::iterator itr = rhs.begin(); while (itr != rhs.end()) { this->push_back(std::move(*itr)); diff --git a/include/etl/version.h b/include/etl/version.h index 7ef7d2b3..4d6f366a 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 14 #define ETL_VERSION_MINOR 24 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH)) diff --git a/support/Release notes.txt b/support/Release notes.txt index 5b4e626b..1578bab8 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +14.24.2 +Fixed bug in 'vector of pointers' move constructor. + =============================================================================== 14.24.1 Added compile time functor version of 'create()'.