tlv: avoid misaligned memory access

They cause unit test crashing on ARM platform.

refs: #4609

Change-Id: Ifdb0401529de48b5c08ebcf6938d80ba87ff883d
diff --git a/src/tlv/coordinate-lsa.cpp b/src/tlv/coordinate-lsa.cpp
index dc6919e..fc74241 100644
--- a/src/tlv/coordinate-lsa.cpp
+++ b/src/tlv/coordinate-lsa.cpp
@@ -50,21 +50,12 @@
 CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
 {
   size_t totalLength = 0;
-  size_t doubleLength = 10;
 
-  const uint8_t* doubleBytes1;
   for (auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
-    doubleBytes1 = reinterpret_cast<const uint8_t*>(&*it);
-
-    totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes1, 8);
-    totalLength += block.prependVarNumber(doubleLength);
-    totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicAngle);
+    totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
   }
 
-  const uint8_t* doubleBytes2 = reinterpret_cast<const uint8_t*>(&m_hyperbolicRadius);
-  totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes2, 8);
-  totalLength += block.prependVarNumber(doubleLength);
-  totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicRadius);
+  totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
 
   totalLength += m_lsaInfo.wireEncode(block);
 
@@ -123,17 +114,8 @@
   }
 
   if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::HyperbolicRadius) {
-    val->parse();
-    ndn::Block::element_const_iterator it = val->elements_begin();
-    if (it != val->elements_end() && it->type() == ndn::tlv::nlsr::Double) {
-      m_hyperbolicRadius = *reinterpret_cast<const double*>(it->value());
-
-      ++val;
-    }
-    else {
-      std::cout << "HyperbolicRadius: Missing required Double field" << std::endl;
-      BOOST_THROW_EXCEPTION(Error("HyperbolicRadius: Missing required Double field"));
-    }
+    m_hyperbolicRadius = ndn::tlv::nlsr::readDouble(*val);
+    ++val;
   }
   else {
     std::cout << "Missing required HyperbolicRadius field" << std::endl;
@@ -142,17 +124,7 @@
 
   for (; val != m_wire.elements_end(); ++val) {
     if (val->type() == ndn::tlv::nlsr::HyperbolicAngle) {
-      val->parse();
-
-      for (auto it = val->elements_begin(); it != val->elements_end(); ++it) {
-        if (it->type() == ndn::tlv::nlsr::Double) {
-          m_hyperbolicAngle.push_back(*reinterpret_cast<const double*>(it->value()));
-        }
-        else {
-          std::cout << "HyperbolicAngle: Missing required Double field" << std::endl;
-          BOOST_THROW_EXCEPTION(Error("HyperbolicAngle: Missing required Double field"));
-        }
-      }
+      m_hyperbolicAngle.push_back(ndn::tlv::nlsr::readDouble(*val));
     }
   }
 }