From: Francis Dupont Date: Fri, 8 May 2020 20:26:27 +0000 (+0200) Subject: [#1211] Added copy assignment operator to LabelSequence X-Git-Tag: Kea-1.7.9~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=791de32286d0b8e636ddd1dad921eea2537f5ddb;p=thirdparty%2Fkea.git [#1211] Added copy assignment operator to LabelSequence --- diff --git a/src/lib/dns/labelsequence.h b/src/lib/dns/labelsequence.h index 0b0b2bc4e8..63aec202cf 100644 --- a/src/lib/dns/labelsequence.h +++ b/src/lib/dns/labelsequence.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -129,6 +129,26 @@ public: last_label_(ls.last_label_) {} + /// \brief Assignment operator. + /// + /// \note The associated data MUST remain in scope during the lifetime + /// of this LabelSequence, since only the pointers are copied. + /// + /// \note No validation is done on the given data upon construction; + /// use with care. + /// + /// \param ls The LabelSequence to construct a LabelSequence from + LabelSequence& operator=(const LabelSequence& other) { + if (this != &other) { + // Not self-assignment. + data_ = other.data_; + offsets_ = other.offsets_; + first_label_ = other.first_label_; + last_label_ = other.last_label_; + } + return (*this); + } + /// \brief Return the wire-format data for this LabelSequence /// /// The data is returned as a pointer to (the part of) the original