Skip to content

Commit d4878eb

Browse files
DimitryAndricandrei-pavel
authored andcommitted
[#3532] Replace Name::NameString with vector of uint8_t
As noted in the libc++ 19 release notes, it now only provides std::char_traits<> for types char, char8_t, char16_t, char32_t and wchar_t, and any instantiation for other types will fail. Name::NameString is defined as a std::basic_string<uint8_t>, so that will no longer work. Redefine it as a std::vector<uint8_t> instead.
1 parent 27a2fea commit d4878eb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/lib/dns/name.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Name::Name(const std::string &namestring, bool downcase) {
303303
// And get the output
304304
labelcount_ = offsets.size();
305305
isc_throw_assert(labelcount_ > 0 && labelcount_ <= Name::MAX_LABELS);
306-
ndata_.assign(ndata.data(), ndata.size());
306+
ndata_.assign(ndata.data(), ndata.data() + ndata.size());
307307
length_ = ndata_.size();
308308
offsets_.assign(offsets.begin(), offsets.end());
309309
}
@@ -336,7 +336,7 @@ Name::Name(const char* namedata, size_t data_len, const Name* origin,
336336
// Get the output
337337
labelcount_ = offsets.size();
338338
isc_throw_assert(labelcount_ > 0 && labelcount_ <= Name::MAX_LABELS);
339-
ndata_.assign(ndata.data(), ndata.size());
339+
ndata_.assign(ndata.data(), ndata.data() + ndata.size());
340340
length_ = ndata_.size();
341341
offsets_.assign(offsets.begin(), offsets.end());
342342

@@ -347,7 +347,7 @@ Name::Name(const char* namedata, size_t data_len, const Name* origin,
347347
// Drop the last character of the data (the \0) and append a copy of
348348
// the origin's data
349349
ndata_.erase(ndata_.end() - 1);
350-
ndata_.append(origin->ndata_);
350+
ndata_.insert(ndata.end(), origin->ndata_.begin(), origin->ndata_.end());
351351

352352
// Do a similar thing with offsets. However, we need to move them
353353
// so they point after the prefix we parsed before.
@@ -582,7 +582,7 @@ Name::concatenate(const Name& suffix) const {
582582

583583
Name retname;
584584
retname.ndata_.reserve(length);
585-
retname.ndata_.assign(ndata_, 0, length_ - 1);
585+
retname.ndata_.assign(ndata_.data(), ndata_.data() + length_ - 1);
586586
retname.ndata_.insert(retname.ndata_.end(),
587587
suffix.ndata_.begin(), suffix.ndata_.end());
588588
isc_throw_assert(retname.ndata_.size() == length);
@@ -622,7 +622,7 @@ Name::reverse() const {
622622
NameString::const_iterator n0 = ndata_.begin();
623623
retname.offsets_.push_back(0);
624624
while (rit1 != offsets_.rend()) {
625-
retname.ndata_.append(n0 + *rit1, n0 + *rit0);
625+
retname.ndata_.insert(retname.ndata_.end(), n0 + *rit1, n0 + *rit0);
626626
retname.offsets_.push_back(retname.ndata_.size());
627627
++rit0;
628628
++rit1;
@@ -662,7 +662,7 @@ Name::split(const unsigned int first, const unsigned int n) const {
662662
// original name, and append the trailing dot explicitly.
663663
//
664664
retname.ndata_.reserve(retname.offsets_.back() + 1);
665-
retname.ndata_.assign(ndata_, offsets_[first], retname.offsets_.back());
665+
retname.ndata_.assign(ndata_.data() + offsets_[first], ndata_.data() + retname.offsets_.back());
666666
retname.ndata_.push_back(0);
667667

668668
retname.length_ = retname.ndata_.size();

src/lib/dns/name.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class Name {
228228
//@{
229229
private:
230230
/// \brief Name data string
231-
typedef std::basic_string<uint8_t> NameString;
231+
typedef std::vector<uint8_t> NameString;
232232
/// \brief Name offsets type
233233
typedef std::vector<uint8_t> NameOffsets;
234234

0 commit comments

Comments
 (0)