Use ndn_memcpy and ndn_memset based on HAVE_MEMCPY and HAVE_MEMSET
diff --git a/ndn-cpp/encoding/BinaryXMLStructureDecoder.c b/ndn-cpp/encoding/BinaryXMLStructureDecoder.c
index 0d53a3b..e29515d 100644
--- a/ndn-cpp/encoding/BinaryXMLStructureDecoder.c
+++ b/ndn-cpp/encoding/BinaryXMLStructureDecoder.c
@@ -4,7 +4,7 @@
  * BSD license, See the LICENSE file for more information.
  */
 
-#include <memory.h>
+#include "../util/ndn_memory.h"
 #include "BinaryXML.h"
 #include "BinaryXMLDecoder.h"
 #include "BinaryXMLStructureDecoder.h"
@@ -30,12 +30,12 @@
   self->state = ndn_BinaryXMLStructureDecoder_READ_HEADER_OR_CLOSE;    
 }
 
-const char *ndn_BinaryXMLStructureDecoder_findElementEnd
-  (struct ndn_BinaryXMLStructureDecoder *self, const unsigned char *input, unsigned int inputLength) 
+char *ndn_BinaryXMLStructureDecoder_findElementEnd
+  (struct ndn_BinaryXMLStructureDecoder *self, unsigned char *input, unsigned int inputLength) 
 {
   if (self->gotElementEnd)
     // Someone is calling when we already got the end.
-    return (const char *)0;
+    return (char *)0;
   
   struct ndn_BinaryXMLDecoder decoder;
   ndn_BinaryXMLDecoder_init(&decoder, input, inputLength);
@@ -43,7 +43,7 @@
   while (1) {
     if (self->offset >= inputLength)
       // All the cases assume we have some input. Return and wait for more.
-      return (const char *)0;
+      return (char *)0;
     
     if (self->state == ndn_BinaryXMLStructureDecoder_READ_HEADER_OR_CLOSE) {
       // First check for CLOSE.
@@ -54,7 +54,7 @@
         if (self->level == 0) {
           // Finished.
           self->gotElementEnd = 1;
-          return (const char *)0;
+          return (char *)0;
         }
         if (self->level < 0)
           return "ndn_BinaryXMLStructureDecoder_findElementEnd: Unexpected close tag";
@@ -72,9 +72,9 @@
             return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't store more header bytes than the size of headerBuffer";
           self->useHeaderBuffer = 1;
           unsigned int nNewBytes = self->headerLength - startingHeaderLength;
-          memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
+          ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
             
-          return (const char *)0;
+          return (char *)0;
         }
         unsigned int headerByte = (unsigned int)input[self->offset++];
         ++self->headerLength;
@@ -90,7 +90,7 @@
         if (self->headerLength > sizeof(self->headerBuffer))
           return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't store more header bytes than the size of headerBuffer";
         unsigned int nNewBytes = self->headerLength - startingHeaderLength;
-        memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
+        ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
 
         // Use a local decoder just for the headerBuffer.
         struct ndn_BinaryXMLDecoder bufferDecoder;
@@ -137,7 +137,7 @@
         // Need more.
         self->offset += nRemainingBytes;
         self->nBytesToRead -= nRemainingBytes;
-        return (const char *)0;
+        return (char *)0;
       }
       // Got the bytes. Read a new header or close.
       self->offset += self->nBytesToRead;
diff --git a/ndn-cpp/util/ndn_memory.c b/ndn-cpp/util/ndn_memory.c
new file mode 100644
index 0000000..5863d44
--- /dev/null
+++ b/ndn-cpp/util/ndn_memory.c
@@ -0,0 +1,27 @@
+/* 
+ * Author: Jeff Thompson
+ *
+ * BSD license, See the LICENSE file for more information.
+ */
+
+#include "ndn_memory.h"
+
+#if !HAVE_MEMCPY
+void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len)
+{
+  unsigned int i;
+  
+  for (i = 0; i < len; i++)
+    dest[i] = src[i];
+}
+#endif
+
+#if !HAVE_MEMSET
+void ndn_memset(unsigned char *dest, int val, unsigned int len)
+{
+  unsigned int i;
+  
+  for (i = 0; i < len; i++)
+    dest[i] = (unsigned char)val;
+}
+#endif
\ No newline at end of file
diff --git a/ndn-cpp/util/ndn_memory.h b/ndn-cpp/util/ndn_memory.h
new file mode 100644
index 0000000..07bd24c
--- /dev/null
+++ b/ndn-cpp/util/ndn_memory.h
@@ -0,0 +1,51 @@
+/* 
+ * Author: Jeff Thompson
+ *
+ * BSD license, See the LICENSE file for more information.
+ */
+
+/*
+ * Based on HAVE_MEMCPY and HAVE_MEMSET in config.h, use the library version or a local implementation of memcpy and memset.
+ */
+
+#ifndef NDN_MEMORY_H
+#define	NDN_MEMORY_H
+
+#include "../../config.h"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#if HAVE_MEMCPY
+#include <memory.h>
+/**
+ * Use the library version of memcpy.
+ */
+static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); }
+#else
+/**
+ * Use a local implementation of memcpy instead of the library version.
+ */
+void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len);
+#endif
+
+#if HAVE_MEMSET
+#include <memory.h>
+/**
+ * Use the library version of memset.
+ */
+static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); }
+#else
+/**
+ * Use a local implementation of memset instead of the library version.
+ */
+void ndn_memset(unsigned char *dest, int val, unsigned int len);
+#endif
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
+