name: Add Name::deepCopy to allow memory optimizations

Change-Id: I5c498d7524c497e8d7c8e2d89561ff51d1c64d35
Refs: #3618
diff --git a/src/name.cpp b/src/name.cpp
index 0e1b11c..ba6c146 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -64,6 +64,15 @@
   construct(uri.c_str());
 }
 
+Name
+Name::deepCopy() const
+{
+  Name copiedName(*this);
+  copiedName.m_nameBlock.resetWire();
+  copiedName.wireEncode(); // "compress" the underlying buffer
+  return copiedName;
+}
+
 template<encoding::Tag TAG>
 size_t
 Name::wireEncode(EncodingImpl<TAG>& encoder) const