Browse Source

[2491] Use insert instead of memcpy to append to a vector.

Marcin Siodelski 12 years ago
parent
commit
eb5b276de3
1 changed files with 1 additions and 3 deletions
  1. 1 3
      src/lib/dhcp/option_data_types.cc

+ 1 - 3
src/lib/dhcp/option_data_types.cc

@@ -236,11 +236,9 @@ OptionDataTypeUtil::writeFqdn(const std::string& fqdn,
         isc::dns::Name name(fqdn);
         isc::dns::LabelSequence labels(name);
         if (labels.getDataLength() > 0) {
-            buf.resize(buf.size() + labels.getDataLength());
             size_t read_len = 0;
             const uint8_t* data = labels.getData(&read_len);
-            memcpy(static_cast<void*>(&buf[buf.size() - read_len]),
-                   data, read_len);
+            buf.insert(buf.end(), data, data + read_len);
         }
     } catch (const isc::Exception& ex) {
         isc_throw(BadDataTypeCast, ex.what());